:root {
  --bg: #FFFCE0;
  --text: #2c1810;
  --text-mid: #6b5545;
  --text-light: #8a7a68;
  --tag-bg: rgba(44, 24, 16, 0.06);
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body { background: var(--bg); color: var(--text); }
* { box-sizing: border-box; }

.content-wrap,
.sorter-inner {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.content-wrap::-webkit-scrollbar,
.sorter-inner::-webkit-scrollbar { display: none; }

/* ───── Header ───── */

.header {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 1.5rem 2.5rem;
}
.portfolio-link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}
.portfolio-link:hover { color: var(--text); }

/* ───── Main layout ───── */

.main {
  display: flex;
  flex: 1;
  min-height: 0;
}
.content-wrap {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
}
.content-wrap > #view {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: center;
}

/* ───── Left sorter ───── */

.sorter {
  flex-shrink: 0;
  width: 5.5rem;
  display: flex;
  flex-direction: column;
}
.sorter-inner {
  flex: 1;
  overflow-y: auto;
  padding: 2.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}
.sorter-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.sorter-btn:hover { color: var(--text-mid); }
.sorter-btn.active {
  color: var(--text);
  font-weight: 600;
}
.sorter-tag {
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}
.sorter-sep {
  width: 1px;
  height: 1.5rem;
  background: rgba(44, 24, 16, 0.1);
  flex-shrink: 0;
}

/* ───── Post list ───── */

.post-list {
  padding: 2.5rem 3rem 4rem;
  padding-left: calc(3rem + 12px);
  width: 100%;
  max-width: 52rem;
}

.post-entry {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1.8rem 0;
  margin-left: 0;
  opacity: 0;
  animation: fadeSlide 0.45s ease forwards;
  transition: margin-left 0.2s ease;
}
.post-entry:hover {
  margin-left: -10px;
}

.post-date {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}
.post-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.3;
  transition: color 0.2s ease;
}
.post-snippet {
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.55;
  max-width: 38rem;
  transition: color 0.2s ease;
}
.post-entry:hover .post-date,
.post-entry:hover .post-snippet { color: var(--text-mid); }
.post-entry:hover .post-title { color: var(--text); }
.post-entry:hover .post-tag { color: var(--text); background: rgba(44, 24, 16, 0.1); }

/* Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.post-tag {
  font-size: 0.7rem;
  color: var(--text-mid);
  background: var(--tag-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, background 0.2s ease;
}

/* Sentinel for infinite scroll (invisible trigger) */
.scroll-sentinel { height: 1px; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .post-entry, .article { animation: none !important; opacity: 1 !important; }
  .post-entry:hover { margin-left: 0; }
}

.empty-msg {
  color: var(--text-light);
  font-size: 0.9rem;
  padding: 2.5rem 0;
}
.empty-msg a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--text-mid);
}
.empty-msg a:hover { border-bottom-color: var(--text); }

/* ───── Single post (article view) ───── */

.article {
  padding: 2.5rem 3rem 4rem;
  width: 100%;
  max-width: 48rem;
  min-width: 0;
  overflow-x: hidden;
  opacity: 0;
  animation: fadeSlide 0.5s ease 0.08s forwards;
}
.article .post-date {
  margin-bottom: 0.6rem;
}
.article .post-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.25;
}
.article .post-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}
.article .post-tags {
  margin-bottom: 2rem;
}
.article .post-body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}
.article .post-body p { margin: 0 0 1.3rem; }
.article .post-body h2 { font-size: 1.15rem; font-weight: 600; margin: 2rem 0 0.6rem; }
.article .post-body h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.article .post-body ul,
.article .post-body ol { margin: 0 0 1.2rem; padding-left: 1.25rem; }
.article .post-body img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem 0;
  object-fit: contain;
}
.article .post-body pre {
  background: #2d2419;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-family: 'Consolas', 'Monaco', 'Menlo', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
}
.article .post-body pre code,
.article .post-body pre code.hljs {
  background: #2d2419;
  padding: 0;
  color: #e8e0d5;
}
.article .post-body code {
  font-family: 'Consolas', 'Monaco', 'Menlo', monospace;
  font-size: 0.88em;
  background: rgba(44, 24, 16, 0.12);
  color: var(--text);
  padding: 0.2em 0.45em;
  border-radius: 4px;
}
.article .back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.85rem;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.2s ease;
}
.article .back-link:hover { color: var(--text); }

/* ───── Mobile ───── */

@media (max-width: 640px) {
  .header { padding: 1.25rem 1.5rem; }
  .main { flex-direction: column; }
  .sorter { width: 100%; }
  .sorter-inner {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 1rem 1rem;
    gap: 0.75rem;
  }
  .sorter-btn {
    writing-mode: horizontal-tb;
    transform: none;
  }
  .sorter-sep {
    flex-basis: 100%;
    width: 100%;
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
  }
  .post-list,
  .article { padding: 1.5rem 1.25rem 3rem; }
  .article .post-title { font-size: 1.25rem; }
  .article .post-body { font-size: 0.9rem; }
  .article .post-body pre { font-size: 0.75rem; padding: 0.75rem 1rem; }
}
