:root {
  --bg: #f8f7f4;
  --bg-elevated: #ffffff;
  --bg-subtle: #f1efe9;
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #2f6f65;
  --accent-hover: #24574f;
  --accent-soft: #e6f0ee;
  --border: #e5e2dc;
  --code-bg: #1c222b;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --max-width: 1020px;
  --content-width: 740px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #12151a;
  --bg-elevated: #1a1f27;
  --bg-subtle: #232a35;
  --text: #e6eaf0;
  --text-secondary: #b0bac9;
  --text-muted: #7f8ca0;
  --accent: #5cb3a4;
  --accent-hover: #74c4b6;
  --accent-soft: rgba(92, 179, 164, 0.14);
  --border: #2a323f;
  --code-bg: #0e1116;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.18s ease;
}

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

/* Reading Progress */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 200;
  transition: width 0.08s linear;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.94rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  background: var(--bg-subtle);
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.menu-toggle {
  display: none;
}

/* Main Container */
main {
  flex: 1;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.container-narrow {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 40px 24px 72px;
}

/* Hero Section */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 36px;
  align-items: center;
  padding: 16px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(1.9rem, 3.2vw, 2.55rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 1.02rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero-media {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--bg-elevated);
}

.hero-media img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

/* Section Heading */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.015em;
}

.section-head a {
  font-size: 0.92rem;
  font-weight: 500;
}

/* Cards Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 52px;
}

.card-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.post-card-cover {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.post-card:hover .post-card-cover img {
  transform: scale(1.03);
}

.post-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.post-card h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  line-height: 1.4;
}

.post-card h3 a {
  color: var(--text);
}

.post-card h3 a:hover {
  color: var(--accent);
}

.post-card p {
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  flex: 1;
}

.post-card-footer {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Compact Note List */
.note-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 52px;
}

.note-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.18s ease;
}

.note-item:hover {
  border-color: var(--accent);
}

.note-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-item-title {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--text);
}

.note-item-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.note-item-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Article Page */
.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.article-header h1 {
  margin: 0 0 14px;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.article-cover {
  margin: 24px 0 32px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.article-content h2 {
  margin: 36px 0 14px;
  font-size: 1.38rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.article-content h3 {
  margin: 26px 0 10px;
  font-size: 1.12rem;
}

.article-content p {
  margin: 0 0 18px;
  color: var(--text);
}

.article-content ul,
.article-content ol {
  margin: 0 0 20px;
  padding-left: 22px;
}

.article-content li {
  margin-bottom: 8px;
}

.article-content blockquote {
  margin: 22px 0;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 5px;
}

.code-block {
  position: relative;
  margin: 22px 0;
}

.article-content pre {
  margin: 0;
  padding: 18px 20px;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.88rem;
}

.article-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-family: var(--font-sans);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.94rem;
}

/* Dev Toolbox */
.tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.tool-tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.tool-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tool-panel {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.tool-panel.active {
  display: block;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 16px;
}

.tool-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.tool-textarea,
.tool-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}

.tool-textarea {
  min-height: 220px;
}

.tool-textarea:focus,
.tool-input:focus {
  outline: none;
  border-color: var(--accent);
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.tool-status {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.tool-status.error {
  color: #dc2626;
}

.regex-highlight mark {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 600;
}

.tool-output-box {
  min-height: 120px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Info Box & About */
.info-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.kv-table th,
.kv-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.kv-table th {
  color: var(--text-muted);
  font-weight: 600;
  width: 140px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 28px 24px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 18px;
}

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

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

/* Responsive */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .card-grid,
  .card-grid-2,
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .menu-toggle {
    display: inline-flex;
  }
  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 16px;
    flex-direction: column;
    align-items: stretch;
  }
  .site-nav.open {
    display: flex;
  }
  .note-item {
    flex-direction: column;
    gap: 6px;
  }
}
