/* Default variables (Light mode) */
:root {
  --text-primary: #000000;
  --text-secondary: #666666;
  --bg-primary: #ffffff;
  --link-color: #0066cc;
  --link-hover: #0052a3;
  --code-bg: #f6f8fa;
  --border-color: #e1e4e8;
  --btn-hover-bg: #efefef;
}

/* Dark mode variables - applied via attribute or media query */
[data-theme="dark"],
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --bg-primary: #0d1117;
    --link-color: #79c0ff;
    --link-hover: #a5d6ff;
    --code-bg: #161b22;
    --border-color: #30363d;
    --btn-hover-bg: #21262d;
  }
}

/* Explicit dark mode override */
[data-theme="dark"] {
  --text-primary: #c9d1d9;
  --text-secondary: #8b949e;
  --bg-primary: #0d1117;
  --link-color: #79c0ff;
  --link-hover: #a5d6ff;
  --code-bg: #161b22;
  --border-color: #30363d;
  --btn-hover-bg: #21262d;
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 1rem;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--btn-hover-bg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
}

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

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

h1 {
  font-size: 2rem;
  margin: 2rem 0 1rem 0;
  font-weight: 600;
}

h2 {
  font-size: 1.5rem;
  margin: 1.5rem 0 0.75rem 0;
  font-weight: 600;
}

h3 {
  font-size: 1.25rem;
  margin: 1.25rem 0 0.5rem 0;
  font-weight: 600;
}

.anchor-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8em;
  margin-left: 0.5rem;
  opacity: 0.3;
  transition: opacity 0.2s, color 0.2s;
  user-select: none;
}

.anchor-link:hover {
  opacity: 1;
  color: var(--link-color);
  text-decoration: none;
}

code {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 6px;
  line-height: 1.4;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

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

nav {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

article {
  margin-bottom: 4rem;
}

.post-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav a {
  color: var(--text-primary);
  text-decoration: none;
  margin: 0 1rem;
}

nav a:first-child {
  margin-left: 0;
}

nav a:hover {
  color: var(--link-color);
}

nav .current {
  font-weight: 600;
}

.nav-left {
  display: flex;
  align-items: center;
}

.nav-right {
  display: flex;
  align-items: center;
}

@media (max-width: 600px) {
  nav {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-left,
  .nav-right {
    gap: 1rem;
  }
}

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

.post-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.25rem 0;
}

.post-title {
  flex: 1;
}

.post-date {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
  margin-left: 1rem;
}

/* KEEP favorite posts - just make them bold */
.favorite-post .post-title {
  font-weight: 600;
}


blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--link-color);
  background: var(--code-bg);
  font-style: italic;
  color: var(--text-secondary);
}

blockquote p {
  margin: 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.9rem;
}

.table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  background: var(--code-bg);
  border-bottom: 2px solid var(--border-color);
}

tbody tr:nth-child(even) {
  background: var(--code-bg);
}

tbody tr:hover {
  background: var(--border-color);
}

/* Responsive images */
article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
}

@media (max-width: 600px) {
  .post-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .post-date {
    margin-left: 0;
    margin-top: 0.25rem;
  }
}