/* ===== Theme tokens ===== */
:root {
  --bg:        #1a1a1a;
  --bg-card:   #202020;
  --bg-hover:  #262626;
  --border:    #2e2e2e;
  --border-hi: #3d3d3d;
  --text:      #e8e8e8;
  --text-dim:  #8a8a8a;
  --text-faint:#5f5f5f;
  --accent:    #e8e8e8;
  --maxw:      760px;
  --gap:       14px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 22px 96px;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: #fff; }

/* ===== Two-column layout ===== */
.layout { display: grid; grid-template-columns: 1fr; gap: 32px; }
.profile { order: -1; } /* name/bio first when stacked on mobile */

@media (min-width: 720px) {
  :root { --maxw: 890px; }
  .layout {
    grid-template-columns: 3fr 2fr; /* left 60% (profile) · right 40% (sections) */
    grid-template-areas: "profile links";
    gap: 64px;
    align-items: start;
  }
  .links   { grid-area: links; margin-top: 6px; } /* align first link with the name's cap height */
  .profile { grid-area: profile; order: 0; position: sticky; top: 72px; text-align: left; }
  .profile h1 { line-height: 1.2; }
}

/* ===== Profile (right side) ===== */
.profile h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.profile .bio {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.65;
}
.profile .bio.hidden { display: none; }
.profile .contact {
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.65;
}
.profile .contact a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-hi);
}
.profile .contact a:hover { color: #fff; text-decoration-color: var(--text-dim); }

.bio-toggle {
  margin-top: 10px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: color .12s ease;
}
.bio-toggle:hover { color: var(--text-dim); }

/* ===== Plain-text link list (left side) ===== */
.links { display: flex; flex-direction: column; gap: 22px; }

.link { display: block; }
.link .title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  transition: color .12s ease;
}
.link:hover .title { color: #fff; }
.link .arrow {
  color: var(--text-faint);
  font-size: 13px;
  margin-left: 6px;
  vertical-align: 1px;
  transition: color .12s ease, transform .12s ease;
  display: inline-block;
}
.link:hover .arrow { color: var(--text-dim); transform: translate(2px, -2px); }
.link .subtitle {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Sub-nav (notes pages) ===== */
.subnav {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 34px;
  font-size: 14px;
}
.subnav h1 { font-size: 24px; font-weight: 700; }
.subnav a { color: var(--text-dim); }
.subnav a:hover { color: var(--text); }
.subnav .sep { color: var(--text-faint); }

/* ===== Notes list ===== */
.note-list { display: flex; flex-direction: column; }
.note-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--border);
}
.note-item:hover .note-title { color: #fff; }
.note-title { font-size: 16px; }
.note-date { color: var(--text-faint); font-size: 13.5px; flex-shrink: 0; }

/* writings list: title with a subtitle underneath */
.post-item { align-items: baseline; }
.note-main { min-width: 0; }
.post-sub {
  display: block;
  margin-top: 3px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ===== Rendered markdown (single note) ===== */
.note-head { margin-bottom: 30px; }
.note-head h1 { font-size: 27px; font-weight: 700; letter-spacing: -0.4px; }
.note-head .subtitle { color: var(--text-dim); font-size: 16px; margin-top: 8px; line-height: 1.5; }
.note-head .date { color: var(--text-faint); font-size: 13.5px; margin-top: 8px; }

.markdown { font-size: 16.5px; line-height: 1.7; }
.markdown > * + * { margin-top: 18px; }
.markdown h1, .markdown h2, .markdown h3 {
  font-weight: 700; line-height: 1.3; margin-top: 32px;
}
.markdown h1 { font-size: 23px; }
.markdown h2 { font-size: 20px; }
.markdown h3 { font-size: 17px; }
.markdown p, .markdown li { color: #d8d8d8; }
.markdown a { color: #fff; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-hi); }
.markdown a:hover { text-decoration-color: var(--text-dim); }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown li + li { margin-top: 6px; }
.markdown blockquote {
  border-left: 2px solid var(--border-hi);
  padding-left: 16px;
  color: var(--text-dim);
  font-style: italic;
}
.markdown code {
  background: #2a2a2a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.markdown pre {
  background: #141414;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
}
.markdown pre code { background: none; padding: 0; }
.markdown img,
.markdown video,
.markdown iframe { display: block; max-width: 100%; margin-left: auto; margin-right: auto; border-radius: 8px; }
.markdown img { cursor: zoom-in; }
.markdown hr { border: none; border-top: 1px solid var(--border); }
.markdown h2, .markdown h3, .markdown h4 { scroll-margin-top: 20px; }

/* ===== In-page Table of Contents ===== */
.toc {
  margin: 6px 0 36px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.toc-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.toc a {
  display: block;
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.4;
  transition: color .12s ease;
}
.toc a:hover { color: #fff; }
.toc a.toc-l1 { padding-left: 16px; font-size: 13.5px; }
.toc a.toc-l2 { padding-left: 32px; font-size: 13px; }

/* ===== Lightbox (click-to-zoom images) ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity .18s ease;
}
.lightbox.open { opacity: 1; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.98);
  transition: transform .18s ease;
}
.lightbox.open img { transform: scale(1); }

/* ===== States ===== */
.empty { color: var(--text-dim); font-size: 15px; padding: 20px 0; }

footer {
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .wrap { padding: 48px 18px 72px; }
  .profile h1 { font-size: 25px; }
  .note-item { flex-wrap: wrap; gap: 2px 16px; }
}
