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

/* ==========================================================
   2. Design tokens (dark default)
   ========================================================== */
:root {
  --bg: #1a1a1a;
  --bg-secondary: #252525;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #c47a3a;
  --accent-hover: #d98b4a;
  --border: #333;
  --code-chrome: #2d2d2d;
  --code-body: #1e1e1e;
  --font-mono: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Courier New', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --max-width: 720px;
}

html.light {
  --bg: #f0f0f0;
  --bg-secondary: #e4e4e4;
  --text: #1a1a1a;
  --text-muted: #777;
  --border: #ccc;
  --code-chrome: #d8d8d8;
  --code-body: #f5f5f5;
}

/* ==========================================================
   3. Base
   ========================================================== */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

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

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1.5rem 0;
}

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

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.site-title:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
}
.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
}

/* ==========================================================
   5. Theme toggle button
   ========================================================== */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}
#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ==========================================================
   6. Main content
   ========================================================== */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  flex: 1;
}

/* ==========================================================
   7. Post list (home)
   ========================================================== */
.post-list {
  list-style: none;
}

.post-list-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.post-list-item:first-child {
  padding-top: 0;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-title-link {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.post-title-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ==========================================================
   8. Post single
   ========================================================== */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-content {
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.3rem;
  margin: 2rem 0 1rem;
}

.post-content h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.4rem;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-footer a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ==========================================================
   9. Page (About, etc.)
   ========================================================== */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
}

.page-content {
  line-height: 1.8;
}

.page-content p {
  margin-bottom: 1.25rem;
}

/* ==========================================================
   10. macOS code window chrome
   ========================================================== */
div.highlight {
  position: relative;
  margin: 1.5rem 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding-top: 32px;
  overflow: hidden;
  background: var(--code-body);
}

/* Titlebar background */
div.highlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: var(--code-chrome);
  border-bottom: 1px solid var(--border);
}

/* Traffic light dots */
div.highlight::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow:
    20px 0 0 #ffbd2e,
    40px 0 0 #28c840;
}

div.highlight pre {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Inline code */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-secondary);
  color: var(--accent);
  border-radius: 3px;
  padding: 0.15em 0.4em;
}

/* ==========================================================
   11. Rouge syntax tokens (monokai-inspired)
   ========================================================== */
.highlight .c,
.highlight .cm,
.highlight .c1,
.highlight .cs  { color: #75715e; }  /* comments */
.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt  { color: #66d9ef; }  /* keywords */
.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .s1  { color: #e6db74; }  /* strings */
.highlight .na  { color: #a6e22e; }  /* attribute names */
.highlight .nb  { color: #f8f8f2; }  /* builtins */
.highlight .nc  { color: #a6e22e; }  /* class names */
.highlight .no  { color: #66d9ef; }  /* constants */
.highlight .nf,
.highlight .nx  { color: #a6e22e; }  /* function names */
.highlight .nn  { color: #f8f8f2; }  /* namespaces */
.highlight .nt  { color: #f92672; }  /* tag names */
.highlight .nv,
.highlight .vi,
.highlight .vc,
.highlight .vg,
.highlight .vs  { color: #fd971f; }  /* variables */
.highlight .o,
.highlight .ow  { color: #f92672; }  /* operators */
.highlight .p   { color: #f8f8f2; }  /* punctuation */
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il  { color: #ae81ff; }  /* numbers */
.highlight .err { color: #f92672; }  /* errors */

/* Light theme: adjust code token colors for readability */
html.light .highlight .c,
html.light .highlight .cm,
html.light .highlight .c1,
html.light .highlight .cs  { color: #998; }
html.light .highlight .k,
html.light .highlight .kd,
html.light .highlight .kn,
html.light .highlight .kp,
html.light .highlight .kr,
html.light .highlight .kt  { color: #0077aa; }
html.light .highlight .s,
html.light .highlight .sb,
html.light .highlight .sc,
html.light .highlight .sd,
html.light .highlight .s2,
html.light .highlight .se,
html.light .highlight .sh,
html.light .highlight .si,
html.light .highlight .sx,
html.light .highlight .s1  { color: #aa5500; }
html.light .highlight .na  { color: #008000; }
html.light .highlight .nb  { color: #333; }
html.light .highlight .nc  { color: #008000; }
html.light .highlight .no  { color: #0077aa; }
html.light .highlight .nf,
html.light .highlight .nx  { color: #008000; }
html.light .highlight .nn  { color: #333; }
html.light .highlight .nt  { color: #aa0060; }
html.light .highlight .nv,
html.light .highlight .vi,
html.light .highlight .vc,
html.light .highlight .vg,
html.light .highlight .vs  { color: #aa5500; }
html.light .highlight .o,
html.light .highlight .ow  { color: #aa0060; }
html.light .highlight .p   { color: #333; }
html.light .highlight .mi,
html.light .highlight .mf,
html.light .highlight .mh,
html.light .highlight .mo,
html.light .highlight .il  { color: #6600cc; }
html.light .highlight .err { color: #aa0060; }

/* ==========================================================
   12. Footer
   ========================================================== */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================
   13. Responsive
   ========================================================== */
@media (max-width: 600px) {
  .post-list-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .post-title {
    font-size: 1.4rem;
  }

  .header-inner {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
  }
}
