:root {
  --bg: #0d1117;
  --panel: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --link: #58a6ff;
  --border: #30363d;
  --card-border: #30363d;
  --prose-text: #c9d1d9;
  --tag-border: #484f58;
  --scrollbar-bg: rgba(13, 17, 23, 0.1);
  --scrollbar-thumb: rgba(139, 148, 158, 0.6);
  --scrollbar-thumb-hover: rgba(139, 148, 158, 0.8);
}

:root.light {
  --bg: #ffffff;
  --panel: #f9fafb;
  --text: #1f2937;
  --muted: #6b7280;
  --link: #2563eb;
  --border: #e5e7eb;
  --card-border: #e5e7eb;
  --prose-text: #374151;
  --tag-border: #d1d5db;
  --scrollbar-bg: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb: rgba(107, 114, 128, 0.6);
  --scrollbar-thumb-hover: rgba(107, 114, 128, 0.8);
}

* { box-sizing: border-box; }

html, body { 
  margin: 0; 
  padding: 0; 
  background: var(--bg); 
  color: var(--text); 
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

header, footer { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px; 
  padding: 18px 0; 
}

nav a { 
  color: var(--muted); 
}

nav a.active { 
  color: var(--text); 
}

.toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  min-width: 40px;
  min-height: 40px;
}

.toggle span {
  margin-left: 8px;
  font-size: 14px;
}

.toggle:hover {
  border-color: var(--text);
  color: var(--text);
  transform: translateY(-1px);
  text-decoration: none;
}

.card { 
  background: var(--panel); 
  border: 1px solid var(--card-border); 
  border-radius: 14px; 
  padding: 18px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

h1.title {
  line-height: 1.2;
}

.title { 
  font-size: 28px; 
  font-weight: 700; 
  margin: 0 0 8px; 
}

.subtitle { 
  color: var(--muted); 
  margin: 8px 0 8px; 
}

.grid { 
  display: grid; 
  gap: 16px; 
}

.post-list { 
  display: grid; 
  gap: 12px; 
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag { 
  font-size: 12px; 
  padding: 2px 8px; 
  border: 1px solid var(--tag-border); 
  border-radius: 999px; 
  color: var(--muted);
  background: var(--panel); 
  cursor: pointer;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--bg);
  transform: translateY(-1px);
}

.tag.active {
  background: var(--bg);
}

p, li { 
  line-height: 1.6; 
  font-size: 16px; /* Prevent zoom on iOS */
}

.task-list-item {
    list-style-type: none;
    margin-left: -1em;
}

h1,h2 { 
  margin-top: 1em;
  line-height: 2;
}

/* Custom floating scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 10px;
  transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox scrollbar */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
  scrollbar-gutter: stable;
}

/* Make scrollbar overlay and floating */
body {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* Force overlay scrollbar on webkit browsers */
html {
  overflow: overlay;
}

hr {
    margin: 40px 0;
    border: 0.3px solid var(--border);
    max-width: 40%;
}

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

.social-links {
    color: var(--muted);
}

.social-links a {
    font-size: 0.8em;
    color: var(--muted);
}

/* Mobile responsive styles */
@media (max-width: 600px) {
  .container { 
    max-width: 100%; 
    padding: 8px; 
    margin: 0;
  }

  nav a {
    border-radius: 4px;
    transition: background-color 0.2s ease;
  }

  nav a:hover,
  nav a.active {
    background: var(--panel);
  }

  .title { 
    font-size: 24px;
  }

  .subtitle { 
    font-size: 14px;
  }

  .card { 
    padding: 16px;
  }

  .toggle {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
  }

  .tag { 
    padding: 4px 8px;
  }

  .toggle,
  .tag,
  nav a {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Optimized scrollbar for mobile */
  ::-webkit-scrollbar {
    width: 4px;
  }

  ::-webkit-scrollbar-thumb {
    border-radius: 8px;
  }
}