* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  height: 100%;
}

body {
  font-family:
    "IBM Plex Sans",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  line-height: 1.6;
  color: #1a1a1a;
  background-color: #e8f4f8;
  padding: 20px;
  font-size: 16px;
  overflow-x: hidden;
}

body.dark-mode {
  color: #c8c8c8;
  background-color: #252525;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 10px;
  }

  h1 {
    font-size: 1.3em;
  }

  h2 {
    font-size: 1.1em;
  }
}

h1,
h2,
h3 {
  margin: 1.5em 0 0.5em 0;
  font-weight: 600;
}

h1 {
  font-size: 1.5em;
}

h1:first-child {
  margin-top: 0;
}

h2 {
  font-size: 1.2em;
}

p {
  margin: 1em 0;
}

ul,
ol {
  margin: 1em 0;
  padding-left: 2em;
}

li {
  margin: 0.5em 0;
}

a {
  color: #0066cc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

body.dark-mode a {
  color: #6ba3ff;
}

img {
  max-width: 100%;
  height: auto;
  margin: 1em 0;
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 1em 0;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 1em;
  background-color: #2a2a2a;
  border: 1px solid #2a2a2a;
  border-radius: 4px 4px 0 0;
  border-bottom: none;
  cursor: pointer;
  user-select: none;
}
.codehilight {
  background-color: transparent !important;
}

body.dark-mode .code-block-header {
  background-color: #303030;
  border: 1px solid #444;
  border-bottom: none;
}

.code-block-header:hover {
  background-color: #1a1a1a;
}

body.dark-mode .code-block-header:hover {
  background-color: #383838;
}

.code-block-controls {
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.code-block-toggle {
  font-size: 0.9em;
  color: #666;
}

body.dark-mode .code-block-toggle {
  color: #a0a0a0;
}

.code-copy-btn {
  background: none;
  border: none;
  color: #c8c8c8;
  padding: 0.3em;
  cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.85em;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  transition: opacity 0.2s;
}

.code-copy-btn svg {
  width: 16px;
  height: 16px;
}

body.dark-mode .code-copy-btn {
  color: #c8c8c8;
}

.code-copy-btn:hover {
  opacity: 0.7;
}

body.dark-mode .code-copy-btn:hover {
  opacity: 0.7;
}

.code-copy-btn.copied {
  color: #4d9fff;
}

body.dark-mode .code-copy-btn.copied {
  color: #4d9fff;
}

.code-block-content {
  overflow: hidden;
  transition: max-height 0.3s ease;
  border-radius: 0 0 4px 4px;
}

.code-block-content.collapsed {
  max-height: 0;
}

pre {
  background-color: #363535;
  padding: 1em;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  margin: 0;
  border: 1px solid #2a2a2a;
}

body.dark-mode pre {
  background-color: #2a2a2a;
  border: 1px solid #444;
}

code {
  padding: 0.2em 0.4em;
  font-family: "Courier New", monospace;
}

body.dark-mode pre code {
  /* background-color: #2a2a2a; */
  color: #c8c8c8;
}

pre code {
  background-color: transparent;
  color: #e0e0e0;
  padding: 0;
}

/* Syntax highlighting is now in syntax.css (auto-generated from Pygments) */

.post-list {
  list-style: none;
}

.post-list li {
  margin: 1.5em 0;
  padding: 0;
}

.post-list li a {
  font-size: 1.2em;
}

.post-list li p {
  margin: 0.3em 0 0 0;
}

.post-meta {
  color: #666;
  font-size: 0.9em;
  margin: 0.2em 0 0 0;
}

body.dark-mode .post-meta {
  color: #a0a0a0;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin: 0.3em 0 0 0;
}

.tag {
  display: inline-block;
  background-color: #f0f0f0;
  color: #1a1a1a;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.2s;
}

.tag:hover {
  background-color: #e0e0e0;
  text-decoration: none;
}

body.dark-mode .tag {
  background-color: #353535;
  color: #c8c8c8;
}

body.dark-mode .tag:hover {
  background-color: #404040;
}

/* Fix tag size in post lists (override .post-list li a font-size) */
.post-list .tag {
  font-size: 0.8em;
}

/* Back links */
.back-link {
  margin: 0 0 1em 0;
  font-size: 0.9em;
}

.back-link a {
  color: #666;
}

body.dark-mode .back-link a {
  color: #a0a0a0;
}

/* Tag grid layout */
.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin: 1em 0 2em 0;
}

/* Clickable h2 links */
h2 a {
  color: inherit;
  text-decoration: none;
}

h2 a:hover {
  text-decoration: underline;
}

.nav-links {
  display: flex;
  justify-content: space-between;
  margin: 2em 0;
  padding: 1em 0;
}

.nav-links a {
  padding: 0.5em 1em;
  border: none;
  transition: background-color 0.2s;
  flex-basis: 48%;
}

body.dark-mode .nav-links a {
  border-color: #c8c8c8;
}

.nav-links a:hover {
  text-decoration: none;
  background-color: #f5f5f5;
}

body.dark-mode .nav-links a:hover {
  background-color: #353535;
}

/* Stack nav-links vertically on narrow screens */
@media (max-width: 768px) {
  .nav-links {
    flex-direction: column;
    gap: 1em;
  }

  .nav-links a {
    flex-basis: auto;
    width: 100%;
  }
}

/* Top Navigation Bar */
.top-nav {
  max-width: 1000px;
  margin: 0 auto 1em auto;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-nav .site-name {
  font-size: 1.5em;
  font-weight: 600;
}

.top-nav .site-name a {
  color: #1a1a1a;
  text-decoration: none;
}

body.dark-mode .top-nav .site-name a {
  color: #c8c8c8;
}

.top-nav .nav-right {
  display: flex;
  gap: 1.5em;
  align-items: center;
}

.top-nav .nav-right a {
  color: #1a1a1a;
  text-decoration: none;
}

body.dark-mode .top-nav .nav-right a {
  color: #c8c8c8;
}

.top-nav .nav-right a:hover {
  text-decoration: underline;
}

/* Menu toggle button (hamburger) - hidden by default */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #1a1a1a;
  padding: 0.3em;
  cursor: pointer;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}

body.dark-mode .menu-toggle {
  color: #c8c8c8;
}

.menu-toggle svg {
  width: 28px;
  height: 28px;
}

/* Mobile responsive navigation */
@media (max-width: 768px) {
  .top-nav {
    flex-wrap: wrap;
    position: relative;
  }

  .menu-toggle {
    display: flex;
  }

  .top-nav .nav-right {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 1em;
    padding: 1em 0;
    align-items: flex-start;
  }

  .top-nav .nav-right.nav-open {
    display: flex;
  }
}

.top-nav .nav-right .dark-mode-toggle {
  background: none;
  color: #1a1a1a;
  padding: 0.3em;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: static;
  transition: background-color 0.2s;
}

body.dark-mode .top-nav .nav-right .dark-mode-toggle {
  border-color: #c8c8c8;
  color: #c8c8c8;
}

.top-nav .nav-right .dark-mode-toggle:hover {
  background-color: #f5f5f5;
}

body.dark-mode .top-nav .nav-right .dark-mode-toggle:hover {
  background-color: #353535;
}

.top-nav .nav-right .dark-mode-toggle svg {
  width: 24px;
  height: 24px;
}

/* Search container */
.search-container {
  position: relative;
}

/* Search input */
.search-input {
  border: 0.7px solid #1a1a1a;
  background: none;
  color: #1a1a1a;
  padding: 0.3em 0.8em;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.9em;
  width: 200px;
}

body.dark-mode .search-input {
  border-color: #c8c8c8;
  color: #c8c8c8;
}

.search-input::placeholder {
  color: #666;
}

body.dark-mode .search-input::placeholder {
  color: #a0a0a0;
}

.search-input:focus {
  outline: none;
}

/* Search results dropdown */
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5em;
  width: 400px;
  max-height: 500px;
  overflow-y: auto;
  background: white;
  border: 1px solid #ddd;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

body.dark-mode .search-results {
  background: #2a2a2a;
  border-color: #444;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.search-result-item {
  display: block;
  padding: 1em;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.2s;
}

body.dark-mode .search-result-item {
  border-bottom-color: #444;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

body.dark-mode .search-result-item:hover {
  background-color: #333;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-title {
  font-weight: 600;
  margin-bottom: 0.3em;
  color: #1a1a1a;
}

body.dark-mode .search-result-title {
  color: #e0e0e0;
}

.search-result-meta {
  display: flex;
  gap: 0.8em;
  font-size: 0.85em;
  color: #666;
  margin-bottom: 0.4em;
}

body.dark-mode .search-result-meta {
  color: #999;
}

.search-result-type {
  text-transform: capitalize;
  font-weight: 500;
}

.search-result-summary {
  font-size: 0.9em;
  color: #555;
  line-height: 1.4;
}

body.dark-mode .search-result-summary {
  color: #aaa;
}

.search-no-results {
  padding: 1.5em;
  text-align: center;
  color: #666;
}

body.dark-mode .search-no-results {
  color: #999;
}

.search-no-results code {
  background: #f0f0f0;
  padding: 0.2em 0.4em;
  font-size: 0.9em;
  border-radius: 3px;
}

body.dark-mode .search-no-results code {
  background: #444;
}

@media (max-width: 768px) {
  .search-results {
    width: 90vw;
    max-width: 400px;
  }
  .search-container {
    width: 100%;
  }
  .search-input {
    width: 100%;
  }
}

/* Link buttons (linktree-style) */
.link-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  max-width: 240px;
  margin: 2em auto;
}

.link-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.4em 1em;
  text-align: center;
  text-decoration: none;
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  transition: background-color 0.2s;
  font-weight: 500;
}

.link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-icon svg {
  width: 20px;
  height: 20px;
}

body.dark-mode .link-button {
  color: #c8c8c8;
}

.link-button:hover {
  background-color: #f5f5f5;
  text-decoration: none;
}

body.dark-mode .link-button:hover {
  background-color: #353535;
}

@media (max-width: 768px) {
  .link-button {
    padding: 0.35em 0.9em;
    font-size: 0.95em;
  }
}

/* Main site header with inline dark mode toggle */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.main-header h1 {
  margin: 0;
}

/* Dark mode toggle for main site */
.dark-mode-toggle {
  background: none;
  border: none;
  color: #1a1a1a;
  padding: 0.5em;
  cursor: pointer;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

body.dark-mode .dark-mode-toggle {
  border-color: #c8c8c8;
  color: #c8c8c8;
}

.dark-mode-toggle:hover {
  background-color: #f5f5f5;
}

body.dark-mode .dark-mode-toggle:hover {
  background-color: #353535;
}

.dark-mode-toggle svg {
  width: 24px;
  height: 24px;
}

.dark-mode-toggle .sun-icon {
  display: block;
}

.dark-mode-toggle .moon-icon {
  display: none;
}

body.dark-mode .dark-mode-toggle .sun-icon {
  display: none;
}

body.dark-mode .dark-mode-toggle .moon-icon {
  display: block;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2em 0;
  padding: 1em 0;
  gap: 1em;
  flex-wrap: wrap;
}

.pagination-link {
  padding: 0.5em 1em;
  border: none;
  text-decoration: none;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.pagination-link:hover {
  background-color: #f5f5f5;
  text-decoration: none;
}

body.dark-mode .pagination-link:hover {
  background-color: #353535;
}

.pagination-disabled {
  padding: 0.5em 1em;
  color: #999;
  white-space: nowrap;
}

body.dark-mode .pagination-disabled {
  color: #707070;
}

.pagination-info {
  color: #666;
  font-size: 0.9em;
  white-space: nowrap;
}

body.dark-mode .pagination-info {
  color: #a0a0a0;
}

@media (max-width: 768px) {
  .pagination {
    justify-content: center;
    gap: 0.5em;
  }

  .pagination-link,
  .pagination-disabled {
    padding: 0.4em 0.8em;
    font-size: 0.9em;
  }
}

/* Footer */
.site-footer {
  max-width: 1000px;
  margin: 1em auto 0 auto;
  padding: 1em 0;
  text-align: center;
  color: #666;
  font-size: 0.9em;
  border-top: 1px solid #e0e0e0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}

body.dark-mode .site-footer {
  color: #a0a0a0;
  border-top-color: #3a3a3a;
}

.site-footer p {
  margin: 0.3em 0;
}

/* Callouts (Obsidian-style) */
.callout {
  margin: 1em 0;
  padding: 0;
  border-left: 4px solid rgb(var(--callout-color, 158, 158, 158));
  background-color: rgba(var(--callout-color, 158, 158, 158), 0.1);
  border-radius: 4px;
  overflow: hidden;
}

body.dark-mode .callout {
  background-color: rgba(var(--callout-color, 158, 158, 158), 0.15);
}

.callout-title {
  padding: 0.5em 1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.callout-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.callout-icon svg {
  width: 20px;
  height: 20px;
}

.callout-title-text {
  flex: 1;
}

.callout-content {
  padding: 0 1em 0.5em 1em;
  color: #1a1a1a;
}

body.dark-mode .callout-content {
  color: #c8c8c8;
}

.callout-content p:first-child {
  margin-top: 0;
}

.callout-content p:last-child {
  margin-bottom: 0;
}
