/* ===== CSS Variables & Theme ===== */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-code: #f1f3f5;
  --text: #2b2b2b;
  --text-secondary: #5a5a5a;
  --text-muted: #888888;
  --border: #e0e0e0;
  --accent: #4a7c59;
  --accent-hover: #3a6347;
  --accent-light: rgba(74, 124, 89, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 3px 8px rgba(0, 0, 0, 0.1);
  --radius: 6px;
  --max-width: 820px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  --timeline-line: #d0d0d0;
  --timeline-dot: #4a7c59;
  --tag-csharp: #68217a;
  --tag-python: #306998;
  --tag-algo: #b8860b;
  --tag-web: #2e86ab;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --bg-card: #242442;
  --bg-code: #2a2a4a;
  --text: #d4d4d4;
  --text-secondary: #a0a0b8;
  --text-muted: #707088;
  --border: #3a3a5a;
  --accent: #6aab7b;
  --accent-hover: #8ac99a;
  --accent-light: rgba(106, 171, 123, 0.1);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 3px 8px rgba(0, 0, 0, 0.35);
  --timeline-line: #4a4a6a;
  --timeline-dot: #6aab7b;
  --tag-csharp: #9b6db8;
  --tag-python: #5a9fd4;
  --tag-algo: #d4a832;
  --tag-web: #4ab0d4;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
}

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

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

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.site-subtitle {
  margin-top: 6px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Site Description ===== */
.site-desc {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.site-desc p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== Filter Bar ===== */
.filter-bar {
  padding: 24px 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

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

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

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

/* ===== Search ===== */
.search-area {
  padding: 0 0 8px;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 8px 14px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-body);
  transition: border-color 0.2s;
}

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

.search-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== Category Cards ===== */
.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.category-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.category-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.category-card ul {
  list-style: none;
  padding: 0;
}

.category-card li {
  font-size: 0.84rem;
  color: var(--text-secondary);
  padding: 3px 0;
  padding-left: 14px;
  position: relative;
}

.category-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

/* ===== Note Cards ===== */
.notes-section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  transition: box-shadow 0.2s;
}

.note-card:hover {
  box-shadow: var(--shadow-hover);
}

.note-card[hidden] {
  display: none;
}

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

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

.note-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}

.note-tag.csharp { background: var(--tag-csharp); }
.note-tag.python { background: var(--tag-python); }
.note-tag.algo { background: var(--tag-algo); }
.note-tag.web { background: var(--tag-web); }

.note-summary {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.note-disclaimer {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 10px;
  font-style: italic;
}

/* ===== Code Block ===== */
.code-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
}

.code-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.code-block {
  display: none;
  margin-top: 12px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
}

.code-block.open {
  display: block;
}

.code-block pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre;
}

/* ===== Timeline ===== */
.timeline-section {
  padding: 24px 0 32px;
  border-top: 1px solid var(--border);
}

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--timeline-line);
}

.timeline-item {
  position: relative;
  padding-bottom: 18px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--timeline-dot);
  border: 2px solid var(--bg);
}

.timeline-date {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}

.timeline-text {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* ===== Boundary Notice ===== */
.boundary-section {
  padding: 24px 0;
  border-top: 1px solid var(--border);
}

.boundary-notice {
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: 24px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 12px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.footer-record {
  font-size: 0.82rem;
  margin-bottom: 6px;
}

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

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

.footer-copy {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, border-color 0.2s, color 0.2s;
  box-shadow: var(--shadow);
  z-index: 10;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== No Results ===== */
.no-results {
  text-align: center;
  padding: 32px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: none;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .site-header {
    padding: 32px 0 24px;
  }

  .site-header .container {
    flex-direction: column;
    gap: 12px;
  }

  .site-title {
    font-size: 1.3rem;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    gap: 6px;
  }

  .filter-btn {
    padding: 4px 10px;
    font-size: 0.78rem;
  }

  .container {
    padding: 0 16px;
  }

  .back-to-top {
    bottom: 16px;
    right: 16px;
  }
}
