/* =============================================
   TOKENS
   ============================================= */
:root {
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-soft: #4b5563;
  --border: #e5e7eb;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --tag-bg: #f3f4f6;
  --tag-text: #374151;
  --btn-bg: #111827;
  --btn-text: #ffffff;
  --btn-hover: #374151;
  --gradient-title: linear-gradient(135deg, #1e1b4b 0%, #4338ca 100%);
  --gradient-accent: linear-gradient(135deg, #4338ca, #7c3aed);
  --radius: 8px;
  --transition: 0.25s ease;
}

body.dark {
  --bg: #0a0a0a;
  --bg-subtle: #111111;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-soft: #d1d5db;
  --border: #1f2937;
  --link: #60a5fa;
  --link-hover: #93c5fd;
  --tag-bg: #1f2937;
  --tag-text: #d1d5db;
  --btn-bg: #ffffff;
  --btn-text: #000000;
  --btn-hover: #e5e7eb;
  --gradient-title: linear-gradient(135deg, #ffffff 0%, #818cf8 100%);
  --gradient-accent: linear-gradient(135deg, #818cf8, #c4b5fd);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.7;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

/* =============================================
   LAYOUT
   ============================================= */
.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 24px;
}

main { flex: 1; padding: 60px 0 80px; }

/* =============================================
   HEADER / NAV
   ============================================= */
header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  background-color: var(--bg);
  z-index: 100;
  transition: background-color var(--transition), border-color var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none !important;
}

nav { display: flex; align-items: center; gap: 24px; }

nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: color var(--transition);
  text-decoration: none;
}
nav a:hover { color: var(--text); text-decoration: none; }

/* =============================================
   THEME TOGGLE
   ============================================= */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}
.theme-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text);
  border-color: var(--text-muted);
}

/* =============================================
   HERO SECTION (index)
   ============================================= */
.hero {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}

.hero-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.hero h1 {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  background: var(--gradient-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
  max-width: 560px;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-soft);
  max-width: 480px;
  line-height: 1.75;
}

/* =============================================
   FEATURED POST (index)
   ============================================= */
.featured-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4338ca;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

body.dark .featured-label { color: #818cf8; }

.featured-label::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: 2px;
}

.featured-post {
  padding-bottom: 48px;
  margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
}

.featured-post h2 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 12px;
}

.featured-post h2 a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--transition);
}
.featured-post h2 a:hover { color: var(--link); text-decoration: none; }

.featured-post .excerpt {
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.75;
  margin-bottom: 16px;
}

/* =============================================
   POST META
   ============================================= */
.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.post-meta .date {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

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

.post-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

/* =============================================
   TAGS
   ============================================= */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-decoration: none;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}
.tag:hover {
  background: var(--link);
  color: white;
  text-decoration: none;
}

/* =============================================
   POST LIST (index)
   ============================================= */
.posts-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.post-list { list-style: none; }

.post-list-item {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  transition: all var(--transition);
}

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

.post-list-item:hover .post-list-title {
  color: var(--link);
}

.post-list-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
  text-decoration: none;
  transition: color var(--transition);
}

.post-list-excerpt {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.post-list-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  padding-top: 4px;
  text-align: right;
}

/* =============================================
   READ MORE LINK
   ============================================= */
.read-more {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--link);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition), color var(--transition);
}
.read-more:hover { gap: 8px; text-decoration: none; color: var(--link-hover); }
.read-more .arrow { font-size: 0.9rem; }

/* =============================================
   SINGLE POST PAGE
   ============================================= */
.post-header {
  padding-top: 16px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 40px;
}

.post-header .back-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 28px;
  transition: color var(--transition);
  font-weight: 500;
}
.post-header .back-link:hover { color: var(--text); text-decoration: none; }

.post-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 16px;
  max-width: 600px;
}

.post-header .post-meta { margin-bottom: 0; }

/* =============================================
   POST BODY CONTENT
   ============================================= */
.post-body { color: var(--text-soft); font-size: 1.02rem; line-height: 1.85; }

.post-body p { margin-bottom: 24px; }
.post-body p:last-child { margin-bottom: 0; }

.post-body h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-top: 44px;
  margin-bottom: 14px;
  line-height: 1.3;
}

.post-body h3 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 10px;
}

.post-body ul, .post-body ol {
  padding-left: 20px;
  margin-bottom: 24px;
  color: var(--text-soft);
}

.post-body li { margin-bottom: 8px; line-height: 1.7; }

.post-body blockquote {
  border-left: 3px solid #4338ca;
  padding: 12px 0 12px 20px;
  margin: 32px 0;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.7;
}

body.dark .post-body blockquote { border-left-color: #818cf8; }

.post-body code {
  background: var(--tag-bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
}

.post-body pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 28px;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.post-body a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.post-body a:hover { color: var(--link-hover); }

/* =============================================
   POST FOOTER / MORE POSTS
   ============================================= */
.post-footer {
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.post-footer h4 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.more-posts { list-style: none; display: flex; flex-direction: column; gap: 16px; }

.more-post-link {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition);
}
.more-post-link::before {
  content: '→';
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color var(--transition);
}
.more-post-link:hover { color: var(--link); text-decoration: none; }
.more-post-link:hover::before { color: var(--link); }

/* =============================================
   ABOUT PAGE
   ============================================= */
.about-header {
  padding: 16px 0 40px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
}

.about-header h1 {
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: var(--gradient-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 16px;
}

.about-header p {
  font-size: 1.05rem;
  color: var(--text-soft);
  line-height: 1.75;
  max-width: 520px;
}

.about-body { font-size: 1rem; color: var(--text-soft); line-height: 1.85; }
.about-body p { margin-bottom: 22px; }
.about-body h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 36px 0 12px;
  letter-spacing: -0.02em;
}

.about-links { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

.about-link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-soft);
}
.about-link-item a { font-weight: 600; color: var(--link); }
.about-link-item a:hover { color: var(--link-hover); }

/* =============================================
   FOOTER
   ============================================= */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  transition: border-color var(--transition);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-links a:hover { color: var(--text); text-decoration: none; }

/* =============================================
   SEARCH (index)
   ============================================= */
.search-bar {
  position: relative;
  margin-bottom: 40px;
}

.search-bar input {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  padding: 10px 16px 10px 38px;
  border-radius: var(--radius);
  outline: none;
  transition: all var(--transition);
  font-family: inherit;
}

.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus { border-color: #4338ca; background: var(--bg); }
body.dark .search-bar input:focus { border-color: #818cf8; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .featured-post h2 { font-size: 1.4rem; }
  .post-header h1 { font-size: 1.75rem; }
  .about-header h1 { font-size: 1.8rem; }
  .post-list-item { grid-template-columns: 1fr; gap: 4px; }
  .post-list-date { text-align: left; }
  nav a { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* =============================================
   NODE PLAYGROUND
   ============================================= */
.playground-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
.playground-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.2;
  background: var(--gradient-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.playground-hero p {
  font-size: 1rem;
  color: var(--text-soft);
  max-width: 560px;
  line-height: 1.7;
}

.editor-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  background: #0d1117;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}
.editor-toolbar-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b949e;
  display: flex;
  align-items: center;
  gap: 8px;
}
.editor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb950;
}
.run-btn {
  background: linear-gradient(135deg, #238636, #2ea043);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: filter var(--transition), transform var(--transition);
}
.run-btn:hover { filter: brightness(1.1); }
.run-btn:active { transform: scale(0.97); }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.code-area {
  width: 100%;
  min-height: 320px;
  background: #0d1117;
  color: #c9d1d9;
  border: none;
  outline: none;
  resize: vertical;
  padding: 16px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 2;
}

.output-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0d1117;
}
.output-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}
.output-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b949e;
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.preview-btn:hover { background: #30363d; color: #fff; }
.output-area {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
}
.output-line-err { color: #f85149; }
.output-line-warn { color: #d29922; }
.output-line-ok { color: #3fb950; }
.output-line-dim { color: #8b949e; }
.output-empty { color: #6e7681; font-style: italic; }

.snippet-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.snippet-chip {
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.snippet-chip:hover { background: var(--link); color: #fff; border-color: var(--link); }

.playground-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.8);
  align-items: center;
  justify-content: center;
}
.playground-modal-card {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 14px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  width: min(960px, 94vw);
  height: min(640px, 90vh);
  overflow: hidden;
}
.playground-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #1e293b;
  background: #1e293b;
}
.playground-modal-toolbar span.lbl {
  color: #4ade80;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.playground-modal-addr {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 7px 10px;
}
.playground-modal-addr input {
  flex: 1;
  background: transparent;
  color: #e2e8f0;
  font-size: 12px;
  font-family: monospace;
  outline: none;
  border: none;
  min-width: 0;
}
.playground-modal-body {
  flex: 1;
  overflow: hidden;
  background: #0f172a;
  position: relative;
  min-height: 0;
}
.playground-modal-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.playground-modal-status {
  padding: 7px 16px;
  border-top: 1px solid #1e293b;
  background: #1e293b;
  font-size: 10px;
  color: #64748b;
  font-family: monospace;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
