/* Theme variables */
:root {
  --bg:              #0a0a0a;
  --text-base:       #e5e5e5;
  --text-strong:     #fff;
  --text-em:         #aaa;
  --text-muted:      #ccc;
  --text-dim:        #888;
  --heading:         #fff;
  --link:            #7c6ff5;
  --link-hover:      #9d93f7;
  --badge-bg:        #1a1a2e;
  --badge-color:     #9d93f7;
  --avatar-border:   #333;
  --border-dim:      #333;
  --border-subtle:   #1a1a1a;
  --border-med:      #555;
  --surface:         #111;
  --surface-border:  #222;
  --code-bg:         #1a1a2e;
  --code-color:      #c4b5fd;
  --quote-border:    #333;
  --quote-color:     #999;
  --footer-color:    #555;
  --footer-link:     #888;
  --footer-hover:    #fff;
  --toggle-border:   #333;
  --toggle-hover-bg: #1a1a1a;
}
[data-theme="light"] {
  --bg:              #fafafa;
  --text-base:       #1a1a1a;
  --text-strong:     #000;
  --text-em:         #555;
  --text-muted:      #333;
  --text-dim:        #666;
  --heading:         #000;
  --link:            #5044c4;
  --link-hover:      #3d34a8;
  --badge-bg:        #edeaff;
  --badge-color:     #5044c4;
  --avatar-border:   #ddd;
  --border-dim:      #ddd;
  --border-subtle:   #e5e5e5;
  --border-med:      #bbb;
  --surface:         #f4f4f4;
  --surface-border:  #e0e0e0;
  --code-bg:         #edeaff;
  --code-color:      #5044c4;
  --quote-border:    #ccc;
  --quote-color:     #666;
  --footer-color:    #aaa;
  --footer-link:     #888;
  --footer-hover:    #333;
  --toggle-border:   #ddd;
  --toggle-hover-bg: #f0f0f0;
}

/* Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-base);
  font-size: 16px;
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--link); }
a:hover { color: var(--link-hover); }
strong { color: var(--text-strong); }
em { color: var(--text-em); }

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--heading);
  margin: 2.5rem 0 1rem;
}
p {
  margin-bottom: 1.25rem;
  color: var(--text-muted);
}
ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-muted);
}
li { margin-bottom: 0.5rem; }

/* Components */
.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-color);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.avatar {
  display: block;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  border: 2px solid var(--avatar-border);
}
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  text-align: center;
}
.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5rem 0;
}
.meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 2.5rem;
}

/* Layout */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem;
  text-align: center;
}

/* Links row */
.links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.links a {
  color: var(--text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-size: 1rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  transition: all 0.2s;
}
.links a:hover {
  color: var(--text-strong);
  border-color: var(--border-med);
}

/* Skills list */
.skills {
  text-align: left;
  margin-bottom: 2rem;
  list-style: none;
  padding-left: 0;
}
.skill {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.5;
}
.skill-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.skill-text strong { color: var(--text-strong); }

/* Blog header */
.blog-header {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.blog-header a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
}
.blog-header a:hover { color: var(--text-strong); }

/* Theme toggle button */
#theme-toggle {
  background: none;
  border: 1px solid var(--toggle-border);
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-dim);
}
#theme-toggle:hover {
  border-color: var(--border-med);
  background: var(--toggle-hover-bg);
}
/* Tweet embed responsive */
.tweet-embed {
  margin: 1.5rem auto;
  max-width: 550px;
}

article {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
}
code {
  background: var(--code-bg);
  color: var(--code-color);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}
pre {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
}
pre code {
  background: none;
  padding: 0;
  color: var(--text-muted);
}
blockquote {
  border-left: 3px solid var(--quote-border);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--quote-color);
  font-style: italic;
}
.diagram {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
}
article img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0 1.5rem;
}
.blog-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  color: var(--footer-color);
  font-size: 0.85rem;
}
.blog-footer a { color: var(--footer-link); text-decoration: none; }
.blog-footer a:hover { color: var(--footer-hover); }

/* Index page centered layout */
body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* Utility */
hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2.5rem 0;
}

/* Mobile readability and overflow protection */
@media (max-width: 600px) {
  h1 { font-size: 1.75rem; }
  .container { padding: 1.5rem 1rem; }
  .top-bar { top: 0.75rem; right: 0.75rem; }
  .links { gap: 0.75rem; }
  .blog-header {
    gap: 0.75rem;
    padding: 1rem;
  }
  article { padding: 1rem 1rem 3rem; }
  .blog-footer { padding: 0 1rem 2rem; }
  pre {
    max-width: 100%;
    padding: 0.875rem;
    font-size: 0.8125rem;
  }
  .diagram {
    max-width: 100%;
    padding: 1rem;
    font-size: 0.7rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }
}
