/* ============ 主题变量 ============ */
:root {
  --bg: #f4f5fb;
  --bg-soft: #ffffff;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(120, 120, 200, 0.12);
  --text: #2a2a3d;
  --text-secondary: #6b6b85;
  --accent: #7b5cff;
  --accent-2: #38bdf8;
  --accent-grad: linear-gradient(135deg, #7b5cff 0%, #38bdf8 100%);
  --header-bg: rgba(255, 255, 255, 0.75);
  --shadow: 0 8px 30px rgba(80, 80, 160, 0.10);
  --overlay-bg: rgba(20, 20, 40, 0.45);
  --tag-bg: rgba(123, 92, 255, 0.10);
  --tag-text: #6b4dff;
  --code-bg: #f0f1f8;
  --quote-border: #c9b8ff;
}

html[data-theme="dark"] {
  --bg: #101018;
  --bg-soft: #17171f;
  --card: rgba(28, 28, 40, 0.85);
  --card-border: rgba(140, 140, 220, 0.12);
  --text: #e8e8f2;
  --text-secondary: #9a9ab2;
  --accent: #9d7bff;
  --accent-2: #4cc9f0;
  --header-bg: rgba(16, 16, 24, 0.78);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --overlay-bg: rgba(0, 0, 0, 0.55);
  --tag-bg: rgba(157, 123, 255, 0.14);
  --tag-text: #b49dff;
  --code-bg: #22222e;
  --quote-border: #6a5bb8;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(123, 92, 255, 0.10), transparent 36%),
    radial-gradient(circle at 88% 8%, rgba(56, 189, 248, 0.10), transparent 30%),
    radial-gradient(circle at 70% 90%, rgba(123, 92, 255, 0.07), transparent 34%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
}

body.radio-open { padding-bottom: 110px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

img { max-width: 100%; display: block; }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--card-border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-grad);
  font-size: 17px;
  box-shadow: 0 4px 14px rgba(123, 92, 255, 0.35);
}

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 15px;
  transition: color 0.2s, background 0.2s;
}
.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
  background: var(--tag-bg);
  text-decoration: none;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: color 0.2s, background 0.2s;
}
.icon-btn:hover { color: var(--text); background: var(--tag-bg); }

html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: block; }

.menu-toggle { display: none; }

/* ============ 布局 ============ */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.content { min-width: 0; }

/* ============ 文章卡片 ============ */
.post-card {
  display: flex;
  gap: 20px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  animation: fadeUp 0.4s ease both;
}
.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 14px 40px rgba(123, 92, 255, 0.18);
}

.post-info { flex: 1; min-width: 0; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.post-category {
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 600;
}

.post-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.post-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text);
}

.post-excerpt {
  font-size: 14px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-tags {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

.post-thumb {
  width: 180px;
  height: 120px;
  flex-shrink: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 42px;
  overflow: hidden;
  position: relative;
}
.post-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
}

/* ============ 文章详情 ============ */
.article {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease both;
}

.article-head { margin-bottom: 28px; }

.article .post-title {
  font-size: 28px;
  margin: 12px 0 10px;
}

.article-body { font-size: 15.5px; }

.article-body h2 {
  font-size: 21px;
  margin: 30px 0 12px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
}

.article-body h3 {
  font-size: 18px;
  margin: 24px 0 10px;
}

.article-body p { margin-bottom: 14px; }

.article-body ul,
.article-body ol { margin: 0 0 14px 22px; }

.article-body li { margin-bottom: 6px; }

.article-body code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--code-bg);
  padding: 2px 7px;
  border-radius: 6px;
}

.article-body pre {
  background: var(--code-bg);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.article-body pre code { padding: 0; background: none; }

.article-body blockquote {
  border-left: 4px solid var(--quote-border);
  padding: 4px 16px;
  margin: 0 0 16px;
  color: var(--text-secondary);
  background: var(--tag-bg);
  border-radius: 0 10px 10px 0;
}

.article-body img { border-radius: 12px; margin: 8px 0; }

.article-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.back-link {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 14px;
  transition: transform 0.2s;
}
.back-link:hover { transform: translateX(-3px); text-decoration: none; }

.article-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ 侧边栏 ============ */
.sidebar {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.widget {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.widget h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.widget-about {
  text-align: center;
}

.widget-avatar {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  font-size: 34px;
  box-shadow: 0 6px 20px rgba(123, 92, 255, 0.35);
}

.widget-about .name {
  font-weight: 700;
  font-size: 16px;
}

.widget-about .bio {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.widget-list { list-style: none; }
.widget-list li { margin-bottom: 8px; }
.widget-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.widget-list a:hover { background: var(--tag-bg); text-decoration: none; }
.widget-list .count {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--tag-bg);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud .tag {
  padding: 4px 12px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.tag-cloud .tag:hover {
  transform: translateY(-2px);
  background: var(--accent);
  color: #fff;
}

/* ============ 页面标题 ============ */
.page-head {
  margin-bottom: 24px;
  padding: 26px 28px;
  border-radius: 18px;
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease both;
}
.page-head h1 { font-size: 26px; margin-bottom: 6px; }
.page-head p { font-size: 14px; opacity: 0.9; }

/* ============ 友链 / 关于 卡片 ============ */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.friend-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.25s, border-color 0.25s;
}
.friend-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}
.friend-avatar {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: var(--tag-bg);
}
.friend-card h3 { font-size: 16px; margin-bottom: 4px; }
.friend-card p {
  font-size: 13px;
  color: var(--text-secondary);
}

.about-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease both;
}
.about-card h2 {
  font-size: 20px;
  margin: 20px 0 10px;
}
.about-card h2:first-child { margin-top: 0; }
.about-card p { color: var(--text-secondary); font-size: 14.5px; }

/* ============ 搜索浮层 ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  animation: fadeIn 0.2s ease;
}

.overlay-panel {
  width: 100%;
  max-width: 640px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: popIn 0.25s ease;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-secondary);
}
.search-input-row input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.search-results { max-height: 50vh; overflow-y: auto; padding: 10px; }
.search-results .empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 28px 0;
}
.search-item {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
  transition: background 0.2s;
}
.search-item:hover { background: var(--tag-bg); text-decoration: none; }
.search-item .t {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}
.search-item .s {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ 快捷键面板 / 中控台 ============ */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
}
.panel-head h2 { font-size: 18px; }

.shortcut-grid,
.console-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px 20px 20px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--tag-bg);
}
.shortcut-item kbd {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-grad);
  color: #fff;
  padding: 3px 9px;
  border-radius: 7px;
  white-space: nowrap;
}
.shortcut-item span { font-size: 13.5px; color: var(--text); }

.console-item {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
}
.console-item .num {
  font-size: 24px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.console-item .label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  padding-bottom: 16px;
}

/* ============ AI 对话 ============ */
.ai-panel {
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.ai-mode-badge {
  margin-left: auto;
  margin-right: 10px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
}

.ai-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-msg.bot {
  align-self: flex-start;
  background: var(--tag-bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--accent-grad);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg a {
  color: var(--tag-text);
  font-weight: 600;
}

.ai-msg.user a { color: #fff; }

.ai-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--card-border);
}

.ai-input-row input {
  flex: 1;
  border: 1px solid var(--card-border);
  outline: none;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 12px;
  font-family: inherit;
}

.ai-input-row input:focus { border-color: var(--accent); }

.ai-send-btn {
  padding: 0 20px;
  border-radius: 12px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s, opacity 0.15s;
}

.ai-send-btn:hover { transform: translateY(-1px); opacity: 0.92; }

/* ============ 电台播放器 ============ */
.radio-bar {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.radio-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 14px;
  animation: radioPulse 2s ease-in-out infinite;
}

.radio-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.radio-track {
  color: var(--text);
  font-weight: 600;
}

.radio-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.radio-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.radio-btn:hover {
  background: var(--tag-bg);
  color: var(--text);
}

.radio-btn#radioPlay {
  width: 40px;
  height: 40px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 15px;
}

.radio-btn#radioPlay:hover { opacity: 0.92; }

@keyframes radioPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123, 92, 255, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(123, 92, 255, 0); }
}

/* ============ 返回顶部 ============ */
.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.back-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-top:hover { transform: translateY(-3px); }

body.radio-open .back-top { bottom: 92px; }

/* ============ 页脚 ============ */
.site-footer {
  text-align: center;
  padding: 30px 20px 40px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============ 动画 ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

@media (max-width: 720px) {
  .menu-toggle { display: grid; }
  .main-nav {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--header-bg);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--card-border);
    padding: 10px 16px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
  }
  .main-nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
    background: var(--bg-soft);
  }
  .post-card { flex-direction: column-reverse; }
  .post-thumb { width: 100%; height: 160px; }
  .article { padding: 24px 20px; }
  .article .post-title { font-size: 22px; }
  .shortcut-grid,
  .console-grid { grid-template-columns: 1fr; }
}
