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

body {
  background: #fffff8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 72px 20px;
  font-family: 'Mundo Serif', Georgia, serif;
  font-weight: 200;
  color: #4a4a4a;
}

.page {
  max-width: 920px;
  width: 100%;
}

.name {
  font-family: 'Mundo Serif Pro Italic', 'Mundo Serif Pro', Georgia, serif;
  font-style: italic;
  font-size: 48px;
  font-weight: 400;
  color: #1a1a1a;
  letter-spacing: -0.5px;
  margin-bottom: 40px;
}

.name a {
  color: inherit;
  text-decoration: none;
  border-bottom: none;
}

.layout {
  display: flex;
  gap: 0;
}

.sidebar {
  width: 180px;
  flex-shrink: 0;
  padding-right: 20px;
  padding-top: 28px;
}

.sidebar-section {
  margin-bottom: 28px;
}

.sidebar-link {
  display: block;
  font-size: 17px;
  line-height: 1.7;
  color: #888;
  text-decoration: none;
  border-bottom: none;
  transition: color 0.2s;
}

.sidebar-link:hover {
  color: #4a4a4a;
}

.sidebar-link.active {
  color: #4a4a4a;
}

.sidebar-social {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.social-logo {
  display: block;
  width: 18px;
  height: 18px;
  color: #bbb;
  border-bottom: none;
  transition: color 0.2s;
}

.social-logo:hover {
  color: #4a4a4a;
  border-bottom: none;
}

.social-logo svg {
  width: 100%;
  height: 100%;
}

.content {
  flex: 1;
  min-width: 0;
  padding-left: 20px;
  font-size: 16px;
  line-height: 1.8;
}

a {
  color: #4a4a4a;
  text-decoration: none;
  border-bottom: 1px solid #ddd;
  transition: border-color 0.2s;
}

a:hover {
  border-bottom-color: #4a4a4a;
}

/* home page */

.section-title {
  font-weight: 700;
  font-style: italic;
  font-size: 15px;
  color: #1a1a1a;
  margin-top: 28px;
  margin-bottom: 4px;
}

.section-title:first-child {
  margin-top: 0;
}

.item {
  padding-left: 18px;
  position: relative;
}

.item::before {
  content: '\2013';
  position: absolute;
  left: 0;
  color: #ccc;
}

.projects .item {
  margin-bottom: 2px;
}

.project-name {
  font-weight: 400;
  font-style: italic;
}

.project-date {
  font-size: 13px;
  color: #aaa;
  margin-top: 2px;
}

.project-links {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.project-link-icon {
  display: block;
  width: 16px;
  height: 16px;
  color: #bbb;
  border-bottom: none;
  transition: color 0.2s;
}

.project-link-icon:hover {
  color: #4a4a4a;
  border-bottom: none;
}

.project-link-icon svg {
  width: 100%;
  height: 100%;
}

.project-ext {
  font-size: 12px;
  color: #bbb;
  margin-left: 6px;
  border-bottom: none;
  text-decoration: none;
  transition: color 0.2s;
}

.project-ext:hover {
  color: #888;
  border-bottom: none;
}

.project-ref {
  font-size: 13px;
  color: #aaa;
}

.project-ref a {
  color: #aaa;
  border-bottom: none;
}

.project-ref a:hover {
  color: #4a4a4a;
}

.item-ref {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-left: 18px;
  position: relative;
}

.item-ref::before {
  content: '\2013';
  position: absolute;
  left: 0;
  color: #ccc;
}

.item-ref .ref {
  font-size: 13px;
  color: #aaa;
  white-space: nowrap;
  margin-left: 16px;
}

.item-ref .ref a {
  color: #aaa;
  border-bottom: none;
}

.item-ref .ref a:hover {
  color: #4a4a4a;
}

/* ascii wave */

.ascii-wave {
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  line-height: 1.2;
  color: #d0d0d0;
  margin-top: 60px;
  user-select: none;
  pointer-events: none;
  overflow: hidden;
  white-space: pre;
}

.divider {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 28px 0;
}

/* list pages (writing, projects) */

.article-item,
.project-item {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #e8e8e8;
}

.article-item:first-child,
.project-item:first-child {
  border-top: 1px solid #e8e8e8;
  padding-top: 16px;
}

.article-title,
.project-title {
  font-weight: 400;
  font-size: 16px;
}

.article-title a,
.project-title a {
  color: #4a4a4a;
  text-decoration: none;
  border-bottom: 1px solid #ddd;
  transition: border-color 0.2s;
}

.article-title a:hover,
.project-title a:hover {
  border-bottom-color: #4a4a4a;
}

.article-date,
.project-desc {
  font-size: 14px;
  color: #888;
}

/* article pages */

.article-header {
  margin-bottom: 28px;
}

.article-header .article-title {
  font-weight: 700;
  font-style: italic;
  font-size: 15px;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.article-header .article-date {
  font-size: 13px;
  color: #aaa;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.article-links {
  display: flex;
  gap: 8px;
}

.article-link-icon {
  display: block;
  width: 14px;
  height: 14px;
  color: #bbb;
  border-bottom: none;
  transition: color 0.2s;
  position: relative;
  top: -4.5px;
}

.article-link-icon:hover {
  color: #4a4a4a;
  border-bottom: none;
}

.article-link-icon svg {
  width: 100%;
  height: 100%;
}

.article-body code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: 0.84em;
  color: #3a3a3a;
  background: #f0efeb;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: -0.01em;
}

.article-body pre {
  background: #f0efeb;
  padding: 16px 20px;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.article-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.82em;
  line-height: 1.6;
}

/* code modal */

.code-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 248, 0.85);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.code-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.code-modal {
  background: #fffff8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 24px 28px;
  max-width: 95vw;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.code-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.code-modal-title {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: #1a1a1a;
}

.code-modal-close {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
  transition: color 0.15s;
}

.code-modal-close:hover {
  color: #4a4a4a;
}

.code-modal pre {
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

.code-modal code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.75;
  color: #3a3a3a;
  background: none;
  padding: 0;
}

.code-modal .line-num {
  color: #c0c0c0;
  display: inline-block;
  width: 24px;
  text-align: right;
  margin-right: 16px;
  user-select: none;
}

.code-modal .kw { color: #7b5ea7; }
.code-modal .type { color: #2a8a6a; }
.code-modal .fn { color: #2a6ab5; }
.code-modal .str { color: #2a8a6a; }
.code-modal .num { color: #c04040; }
.code-modal .cmt { color: #5a9a5a; font-style: italic; }
.code-modal .dir { color: #7b5ea7; }

.view-source-link {
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  border-bottom: 1px solid #ddd;
  transition: color 0.2s, border-color 0.2s;
  margin-left: 10px;
  font-style: normal;
  font-weight: 400;
}

.view-source-link:hover {
  color: #4a4a4a;
  border-bottom-color: #4a4a4a;
}

.article-body .katex-display {
  margin: 24px 0;
  overflow-x: auto;
  text-align: center;
}

.article-body .katex-display > .katex > .katex-html {
  display: inline-block;
  padding: 8px 16px;
}

.article-body .katex-html {
  background: #f0efeb;
  padding: 4px 5px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
}

.article-body .katex {
  font-size: 1.05em;
  margin: 0 1px;
  position: relative;
  top: -1px;
}

.article-body p {
  margin-bottom: 20px;
}

.article-body hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 28px 0;
}

.article-body h3 {
  font-weight: 700;
  font-style: italic;
  font-size: 15px;
  color: #1a1a1a;
  margin-top: 32px;
  margin-bottom: 8px;
}

.article-body ol {
  padding-left: 20px;
  margin-bottom: 20px;
}

.article-body ol li {
  margin-bottom: 4px;
}

.article-body img {
  display: block;
  max-width: 100%;
  margin: 8px auto 28px;
}

.preview-with-logo {
  padding: 12px 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.preview-with-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.preview-with-logo .preview-text {
  flex: 1;
  min-width: 0;
}

.preview-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.preview-meta {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-with-logo h3 {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.preview-with-logo p {
  color: #4a4a4a;
  font-size: 12.5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* preview popups */

.preview {
  position: fixed;
  width: 420px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
}

.preview.visible {
  opacity: 1;
}

.preview-wiki {
  padding: 12px 16px;
}

.preview-wiki img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 2px;
  margin-bottom: 10px;
  background: #f8f8f8;
  padding: 12px;
}

.preview-wiki h3 {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #1a1a1a;
}

.preview-wiki p {
  color: #4a4a4a;
  font-size: 12.5px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-github {
  padding: 12px 16px;
}

.preview-github .github-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.preview-github .github-header .meta {
  margin: 0;
  flex-shrink: 0;
}

.preview-github h3 {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.preview-github p {
  color: #4a4a4a;
  font-size: 12.5px;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-github .meta {
  font-size: 11.5px;
  color: #888;
  display: flex;
  gap: 14px;
}

.preview-social {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.preview-social .social-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.preview-social .social-info h3 {
  font-family: 'Mundo Serif', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.preview-social .social-info p {
  font-size: 12px;
  color: #888;
}

/* responsive */

@media (max-width: 700px) {
  body {
    padding: 40px 20px;
  }

  .name {
    font-size: 36px;
    margin-bottom: 28px;
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding-right: 0;
    margin-bottom: 28px;
  }

  .content {
    padding-left: 0;
  }
}
