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

:root {
  --bg: #f6f4ef;
  --bg-sidebar: #f6f4ef;
  --bg-content: #fdfcfa;
  --text: #1a1917;
  --text-muted: #6b6560;
  --text-faint: #9a948d;
  --border: #e3ded6;
  --accent: #2c4a3e;
  --accent-soft: rgba(44, 74, 62, 0.08);
  --sidebar-width: min(44vw, 520px);
  --font-serif: "Literata", "Georgia", serif;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.layout.show-post {
  grid-template-columns: var(--sidebar-width) 1fr;
}

/* —— Sidebar —— */

.sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(2rem, 5vh, 3.5rem) clamp(1.5rem, 4vw, 2.75rem);
  background: var(--bg-sidebar);
}

.layout:not(.show-post) .sidebar {
  max-width: 38rem;
  width: 100%;
  margin: 0 auto;
  text-align: left;
}

.layout.show-post .sidebar {
  border-right: 1px solid var(--border);
}

.site-header {
  margin-bottom: 2.75rem;
}

.site-name {
  font-family: var(--font-serif);
  font-size: clamp(1.65rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 1rem;
  color: var(--text);
}

.layout.show-post .site-name {
  cursor: pointer;
}

.site-description {
  margin: 0 0 1.25rem;
  max-width: 36ch;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.layout:not(.show-post) .site-description {
  max-width: none;
}

.site-description p {
  margin: 0 0 0.85rem;
}

.site-description p:last-child {
  margin-bottom: 0;
}

.site-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.35rem 1rem;
}

.site-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.site-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.writings-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.85rem;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.15rem 0.5rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.section-tab {
  padding: 0.35rem 0.5rem;
  margin: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.section-tab:hover {
  color: var(--text-muted);
}

.section-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li + li {
  border-top: 1px solid var(--border);
}

.post-list-empty {
  padding: 0.75rem 0;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.post-link {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.2rem 1rem;
  align-items: baseline;
  width: 100%;
  padding: 1rem 0.35rem;
  margin: 0 -0.35rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background 0.15s ease;
}

.post-link:hover {
  background: var(--accent-soft);
}

.post-link.is-active {
  background: var(--accent-soft);
}

.post-link-title {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
}

.post-link-date {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: start;
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap;
}

/* —— Content pane —— */

.content {
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-content);
  padding: clamp(2rem, 5vh, 3.5rem) clamp(1.5rem, 6vw, 4.5rem);
}

.layout:not(.show-post) .content {
  display: none;
}

.content-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-faint);
  font-size: 0.95rem;
}

.content-empty p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.back-button {
  display: inline-block;
  margin-bottom: 1.5rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}

.back-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

.post-date {
  font-size: 0.85rem;
  color: var(--text-faint);
}

.post-body {
  max-width: 42rem;
}

/* —— Markdown prose —— */

.prose {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin: 2rem 0 0.75rem;
}

.prose h1 { font-size: 1.65rem; }
.prose h2 { font-size: 1.35rem; }
.prose h3 { font-size: 1.15rem; }

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre {
  margin: 0 0 1.15rem;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1.25rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.prose code {
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.88em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.15rem;
  background: #1a1917;
  color: #f0ebe3;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 4px;
  border: 1px solid var(--border);
}

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

/* —— Mobile —— */

@media (max-width: 768px) {
  .layout,
  .layout.show-post {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .layout.show-post .sidebar {
    display: none;
  }

  .layout.show-post .content {
    display: block;
  }

  .layout:not(.show-post) .content {
    display: none;
  }

  .sidebar {
    border-right: none;
    padding-bottom: 3rem;
  }

  .back-button {
    display: inline-block;
  }

  .content-empty {
    display: none;
  }
}

@media (min-width: 769px) {
  .layout.show-post .content-empty {
    display: none;
  }
}

/* —— Reduced motion —— */

@media (prefers-reduced-motion: reduce) {
  .post-link,
  .section-tab {
    transition: none;
  }
}
