:root {
  --bg: #0b0f14;
  --surface: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --border: rgba(255,255,255,0.08);
  --code-bg: #0b1020;
  --inline-code-bg: rgba(99,102,241,0.18);
  --inline-code-text: #e6edff;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --border: rgba(0,0,0,0.08);
    --code-bg: #0a0f1a;
    --inline-code-bg: rgba(37,99,235,0.12);
    --inline-code-text: #1f2937;
  }
}

/* Manual theme override */
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --surface: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --border: rgba(255,255,255,0.08);
  --code-bg: #0b1020;
  --inline-code-bg: rgba(99,102,241,0.18);
  --inline-code-text: #e6edff;
}

:root[data-theme="light"] {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --border: rgba(0,0,0,0.08);
  --code-bg: #0a0f1a;
  --inline-code-bg: rgba(37,99,235,0.12);
  --inline-code-text: #1f2937;
}

html, body {
  padding: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.7;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.04);
  backdrop-filter: blur(6px);
}

.site-title {
  display: inline-block;
  padding: 16px 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.site-actions { float: right; display: flex; gap: 8px; align-items: center; }
.theme-toggle {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,0.14); }
.theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  color: var(--muted);
}
.site-footer p { padding: 16px 0; margin: 0; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-top: 28px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.post-title {
  margin: 0 0 6px 0;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.post-meta {
  color: var(--muted);
  font-size: 14px;
}

.post-content h2,
.post-content h3 {
  margin-top: 28px;
  margin-bottom: 12px;
}

.post-content p,
.post-content ul,
.post-content ol {
  margin: 14px 0;
}

.post-content a { color: var(--primary); }

/* Code & pre blocks */
code, pre, .highlight pre {
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95em;
}

pre, .highlight pre {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(0,0,0,0.08)), var(--code-bg);
  color: #e6edf3;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  overflow: auto;
  margin: 16px 0;
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,0.14); }
.copy-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Inline code */
p code, li code {
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Ensure inline code inside callouts stays readable */
.explain code, blockquote code {
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
}

/* Explanation callout */
.explain, blockquote {
  background: rgba(96,165,250,0.08);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 18px 0;
  color: var(--text);
  border-radius: 8px;
}

/* Post list on home */
.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.post-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.post-list-item:hover { border-color: rgba(96,165,250,0.5); }
.post-list-title { font-weight: 600; }
.post-list-date { color: var(--muted); font-size: 14px; }

/* Problem metadata block */
.problem-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(96,165,250,0.06);
  margin: 14px 0 8px 0;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  font-size: 12px;
}
.difficulty-easy { color: #22c55e; border-color: rgba(34,197,94,0.35); }
.difficulty-medium { color: #f59e0b; border-color: rgba(245,158,11,0.35); }
.difficulty-hard { color: #ef4444; border-color: rgba(239,68,68,0.35); }

/* Accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 16px;
  top: 12px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 1000;
}
