
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Light theme (default) ===== */
:root {
  --text:       #333;
  --heading:    #111;
  --muted:      #888;
  --border:     #e8e8e8;
  --bg:         #fff;
  --sidebar-bg: #fafafa;
  --accent:     #3b82f6;
  --accent-bg:  #eff6ff;
  --code-bg:    #f7f7f7;
  --code-inline:#e83e8c;
  --card-hover: #f8faff;
  --pre-bg:     #1e293b;
  --pre-text:   #e2e8f0;
  --font:       'Noto Sans KR', -apple-system, sans-serif;
  --mono:       'JetBrains Mono', monospace;
}

/* ===== Dark theme ===== */
[data-theme="dark"] {
  --text:       #d1d5db;
  --heading:    #f3f4f6;
  --muted:      #9ca3af;
  --border:     #374151;
  --bg:         #111827;
  --sidebar-bg: #0f172a;
  --accent:     #60a5fa;
  --accent-bg:  rgba(96, 165, 250, 0.1);
  --code-bg:    #1e293b;
  --code-inline:#f472b6;
  --card-hover: #1e293b;
  --pre-bg:     #0f172a;
  --pre-text:   #e2e8f0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  transition: background 0.25s, color 0.25s;
}

a { color: inherit; text-decoration: none; }

/* ===== Layout ===== */

.layout {
  display: flex;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== Sidebar ===== */

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: background 0.25s, border-color 0.25s;
}

.profile {
  text-align: center;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem;
}

.profile-avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0.5rem auto 1.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center -20%;
  transform: scale(1.4);
}

[data-theme="dark"] .profile-avatar {
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.2);
}

.profile-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 0.35rem;
}

.profile-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

/* Social icons */
.social {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.social a {
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.social a:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  transition: border-color 0.15s, background 0.25s;
}

.search-box:focus-within { border-color: var(--accent); }

.search-box svg { flex-shrink: 0; color: var(--muted); }

.search-box input {
  border: none;
  outline: none;
  background: none;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--text);
  width: 100%;
}

.search-box input::placeholder { color: var(--muted); }

.search-results {
  display: none;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  max-height: 280px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--card-hover); }

.search-item-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--heading);
}

.search-item-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.search-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Nav */
.gnb {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.gnb a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.gnb a:hover { background: var(--accent-bg); color: var(--accent); }
.gnb a.active { background: var(--accent-bg); color: var(--accent); }

.gnb svg { flex-shrink: 0; opacity: 0.6; }
.gnb a.active svg { opacity: 1; }

/* Visitor counter */
.visitor-counter {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.visitor-counter b {
  font-weight: 600;
  color: var(--text);
}

.vc-sep { opacity: 0.5; }

/* Comments */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ===== Content ===== */

.content-wrap {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

main {
  max-width: 820px;
  padding: 3.5rem 4rem 5rem;
}

/* ===== Home ===== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--heading);
}

.page-header-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.page-header .search-box {
  margin-bottom: 0;
  width: 200px;
  flex-shrink: 0;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
}

.post-count {
  font-size: 0.88rem;
  color: var(--muted);
}

/* Post cards */
.post-card {
  border-bottom: 1px solid var(--border);
}

.post-card a {
  display: block;
  padding: 1.75rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.post-card a:hover { background: var(--card-hover); }

.post-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.45;
  margin-bottom: 0.6rem;
}

.post-card-desc {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 0.85rem;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.post-card-meta time {
  font-size: 0.85rem;
  color: var(--muted);
}

.post-card-tags { display: flex; gap: 0.3rem; }

/* Tags */
.tag {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  white-space: nowrap;
}

/* ===== Post page ===== */

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.post-category { margin-bottom: 0.75rem; display: flex; gap: 0.35rem; }

.post-title {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post-info time {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Post body */
.post-body {
  font-size: 1.05rem;
  line-height: 1.85;
}

.post-body > * + * { margin-top: 1.25rem; }

.post-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 3rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.post-body h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 2.25rem;
}

.post-body h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 1.75rem;
}

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(59, 130, 246, 0.3);
  text-underline-offset: 2px;
}
.post-body a:hover { text-decoration-color: var(--accent); }

.post-body ul, .post-body ol { padding-left: 1.5rem; }
.post-body li { margin-top: 0.35rem; }

.post-body strong { font-weight: 700; color: var(--heading); }

/* Inline code */
.post-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--code-inline);
  padding: 0.15em 0.45em;
  border-radius: 3px;
}

/* Code block */
.post-body pre {
  background: var(--pre-bg);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.post-body pre code {
  font-family: var(--mono);
  font-size: 0.92rem;
  line-height: 1.7;
  background: none;
  border: none;
  color: var(--pre-text);
  padding: 0;
}

/* Blockquote */
.post-body blockquote {
  background: var(--accent-bg);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  color: var(--muted);
}

.post-body blockquote p { margin: 0; }

/* Table */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 1.75rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.post-body th, .post-body td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

.post-body th {
  background: var(--code-bg);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--muted);
}

.post-body tr:last-child td { border-bottom: none; }

/* Image */
.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

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

/* Post nav */
.post-nav {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-nav a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  transition: opacity 0.15s;
}

.post-nav a:hover { opacity: 0.7; }

/* ===== About ===== */

.about {
  line-height: 1.85;
  font-size: 1rem;
}

.about h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 0.25rem;
}

.about h1 + p { color: var(--text); font-weight: 500; margin-bottom: 1.5rem; }

.about h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

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

.about strong { font-weight: 700; color: #2563eb; }
[data-theme="dark"] .about strong { color: #60a5fa; }

.about ul { padding-left: 1.25rem; margin-top: 0.5rem; }
.about li { margin-top: 0.3rem; color: var(--text); font-size: 0.95rem; }

.about-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.about em { font-style: italic; }

/* ===== Misc ===== */

.empty { color: var(--muted); font-size: 0.9rem; padding: 3rem 0; text-align: center; }

/* ===== Syntax (One Dark) ===== */

.highlight { background: var(--pre-bg) !important; border-radius: 8px; }
.highlight .c, .highlight .c1, .highlight .cm { color: #5c6370; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn { color: #c678dd; }
.highlight .nf { color: #61afef; }
.highlight .nc { color: #e5c07b; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #98c379; }
.highlight .m, .highlight .mi, .highlight .mf { color: #d19a66; }
.highlight .nb { color: #56b6c2; }
.highlight .o  { color: #abb2bf; }
.highlight .nx { color: #abb2bf; }
.highlight .na { color: #d19a66; }
.highlight .kr { color: #c678dd; }
.highlight .kt { color: #e5c07b; }
.highlight .se { color: #d19a66; }
.highlight .p  { color: #abb2bf; }

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
  }

  .profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    padding-bottom: 1.25rem;
  }

  .profile-avatar { width: 48px; height: 48px; margin: 0; flex-shrink: 0; }
  .profile-name { font-size: 0.95rem; }
  .profile-desc { font-size: 0.75rem; margin-bottom: 0.5rem; }
  .social { justify-content: flex-start; }
  .social a { width: 28px; height: 28px; }

  .gnb { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
  .gnb a { font-size: 0.82rem; padding: 0.4rem 0.65rem; }
  .gnb svg { display: none; }

  .sidebar-footer { display: none; }

  main { padding: 2rem 1.5rem 4rem; }
}
