/* Personal blog — dark theme, responsive */

:root {
  --bg: #0c0e12;
  --bg-elevated: #13161d;
  --bg-card: #181c26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaed;
  --text-muted: #9aa0a8;
  --accent: #6ee7b7;
  --accent-dim: rgba(110, 231, 183, 0.15);
  --accent-btn-start: #34d399;
  --accent-btn-end: #6ee7b7;
  --link: #7dd3fc;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", ui-monospace, monospace;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --max-width: 720px;
  --header-h: 64px;
  --footer-bg: #07080c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(110, 231, 183, 0.12), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(125, 211, 252, 0.06), transparent 45%);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: rgba(12, 14, 18, 0.85);
  backdrop-filter: blur(12px);
}

.site-header__inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.logo span {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.theme-toggle {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  border-color: rgba(110, 231, 183, 0.4);
  background: var(--accent-dim);
}

html[data-theme="light"] .theme-toggle__icon--moon {
  display: none;
}

html:not([data-theme="light"]) .theme-toggle__icon--sun {
  display: none;
}

.nav a {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.nav a:hover {
  color: var(--text);
  background: var(--accent-dim);
  text-decoration: none;
}

.nav a.is-active {
  color: var(--accent);
  background: var(--accent-dim);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.hero {
  padding: 1rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.hero p {
  margin: 0;
  max-width: 42rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.section-title {
  margin: 0 0 1.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  display: block;
  padding: 1.25rem 1.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.2s;
}

.post-card:hover {
  border-color: rgba(110, 231, 183, 0.35);
  transform: translateY(-2px);
  text-decoration: none;
}

.post-card__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.post-card__title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.post-card__excerpt {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.page-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 0 0 2rem;
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--accent);
}

.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.article-header time {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* 分类样式 */
.article-category {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.article-category svg {
  opacity: 0.7;
}
.article-category a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}
.article-category a:hover {
  opacity: 0.8;
}

/* 标签样式 */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}
.meta-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.article-body {
  max-width: var(--max-width);
}

/* Markdown prose */
.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  margin: 1.75rem 0 0.75rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.article-body h1:first-child {
  margin-top: 0;
}

.article-body h2 {
  font-size: 1.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.article-body h3 {
  font-size: 1.15rem;
}

.article-body p {
  margin: 0 0 1rem;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
}

.article-body li {
  margin-bottom: 0.35rem;
}

.article-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-elevated), rgba(110, 231, 183, 0.05));
  color: var(--text-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}
.article-body blockquote p:last-child {
  margin-bottom: 0;
}

.article-body a {
  word-break: break-word;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.4em;
  background: var(--bg-elevated);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.article-body pre {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.6;
  position: relative;
}

.article-body pre code {
  padding: 0;
  border: none;
  background: none;
  font-size: inherit;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.article-body th,
.article-body td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  text-align: left;
}
.article-body tr:last-child td {
  border-bottom: none;
}

.article-body th {
  background: var(--bg-elevated);
  font-weight: 600;
}

.article-body tr:hover td {
  background: rgba(110, 231, 183, 0.03);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 1.5rem auto;
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* 图片标题/说明 */
.article-body img + em {
  display: block;
  text-align: center;
  margin-top: -1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 链接样式 */
.article-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.article-body a:hover {
  border-bottom-color: var(--accent);
}

/* 强调文字 */
.article-body strong {
  color: var(--accent);
  font-weight: 600;
}

/* 任务列表 */
.article-body input[type="checkbox"] {
  margin-right: 0.5em;
  accent-color: var(--accent);
}

/* 脚注 */
.article-body .footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.msg {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.msg--error {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.site-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer--rich {
  max-width: none;
  background: var(--footer-bg);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: left;
  padding: 2.5rem 1.25rem 3rem;
}

.footer-grid {
  max-width: 960px;
  margin: 0 auto 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
}

@media (min-width: 640px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.footer-col__title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-col li {
  margin-bottom: 0.4rem;
}

.footer-col a {
  color: var(--text);
  font-size: 0.92rem;
}

.footer-col a:hover {
  color: var(--accent);
}

.footer-note {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb__sep {
  margin: 0 0.35rem;
  opacity: 0.6;
}

.tag-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 520px) {
  .tag-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 860px) {
  .tag-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tag-card {
  position: relative;
  display: block;
  padding: 1.15rem 1.2rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(
    135deg,
    hsla(var(--tag-hue), 42%, 22%, 0.95),
    hsla(calc(var(--tag-hue) + 40), 38%, 18%, 0.92)
  );
  box-shadow: var(--shadow);
  min-height: 5.5rem;
  transition: transform 0.2s, border-color 0.2s;
}

.tag-card:hover {
  transform: translateY(-3px);
  border-color: rgba(110, 231, 183, 0.35);
  text-decoration: none;
}

.tag-card__name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.tag-card__count {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  color: rgba(232, 234, 237, 0.85);
}

.tag-card__arrow {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  font-size: 1.1rem;
  opacity: 0.7;
}

.pin-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-right: 0.35rem;
  vertical-align: middle;
}

.post-card__tags {
  margin: 0.35rem 0 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-pill {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

a.tag-pill--link {
  text-decoration: none;
  color: var(--link);
}

a.tag-pill--link:hover {
  border-color: rgba(110, 231, 183, 0.4);
  color: var(--accent);
  text-decoration: none;
}

.article-tags {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.meta-label {
  color: var(--text-muted);
  margin-right: 0.35rem;
}

.featured-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.featured-msg {
  margin: 0;
  padding: 1rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.featured-msg__text {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.featured-msg__meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.guestbook-form {
  max-width: 32rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-field input,
.form-field textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.btn-primary {
  align-self: flex-start;
  padding: 0.55rem 1.25rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-btn-start), var(--accent-btn-end));
  color: var(--bg);
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.about-prose h2:first-child {
  margin-top: 0;
}

.about-prose .about-code {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
}

.archive-year {
  margin-bottom: 2rem;
}

.archive-year__title {
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.archive-item__date {
  flex: 0 0 3.2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.archive-item__link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.archive-item__link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.article-body .katex {
  font-size: 1.05em;
  color: var(--text);
}

.article-body .katex-display {
  margin: 1.25rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* 浅色主题 */
html[data-theme="light"] {
  --bg: #f3f4f6;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: rgba(0, 0, 0, 0.1);
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #059669;
  --accent-dim: rgba(5, 150, 105, 0.12);
  --accent-btn-start: #059669;
  --accent-btn-end: #10b981;
  --link: #0369a1;
  --danger: #dc2626;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  --footer-bg: #111827;
}

html[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(5, 150, 105, 0.08), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(3, 105, 161, 0.06), transparent 45%);
}

html[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .tag-card {
  background: linear-gradient(
    135deg,
    hsla(var(--tag-hue), 42%, 88%, 0.95),
    hsla(calc(var(--tag-hue) + 40), 38%, 82%, 0.92)
  );
}

/* 浅色主题适配 */
html[data-theme="light"] .article-body blockquote {
  background: linear-gradient(135deg, #f0fdf4, rgba(5, 150, 105, 0.05));
  border-left-color: #059669;
}

html[data-theme="light"] .article-body pre {
  background: #f6f8fa;
  border-color: #d0d7de;
}

html[data-theme="light"] .article-body img {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

html[data-theme="light"] .article-body strong {
  color: #059669;
}

html[data-theme="light"] .article-body table {
  border-color: #d0d7de;
}

html[data-theme="light"] .article-body tr:hover td {
  background: rgba(5, 150, 105, 0.05);
}

html[data-theme="light"] .tag-card__name {
  color: #1f2937;
}

html[data-theme="light"] .tag-card__count {
  color: rgba(31, 41, 55, 0.75);
}

html[data-theme="light"] .tag-card__arrow {
  color: rgba(31, 41, 55, 0.6);
}

html[data-theme="light"] .tag-card:hover {
  border-color: rgba(5, 150, 105, 0.35);
}

html[data-theme="light"] .footer-col a {
  color: #e5e7eb;
}

html[data-theme="light"] .footer-col a:hover {
  color: #6ee7b7;
}

html[data-theme="light"] .site-footer--rich {
  color: #d1d5db;
}

html[data-theme="light"] .footer-col__title,
html[data-theme="light"] .footer-note {
  color: #9ca3af;
}

@media (max-width: 480px) {
  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    height: auto;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    gap: 0.75rem;
  }

  .site-header {
    height: auto;
  }

  main {
    padding-top: 1.75rem;
  }

  .post-card {
    padding: 1rem 1.1rem;
  }
}
