:root {
  --bg: #fcf6e6;
  --panel: #f7efd9;
  --text: #4a4236;
  --muted: #8c8371;
  --line: #e8dec4;
  --accent: #8a5a2b;
  --code-bg: #f1e8cf;
  --font: "Lora", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.7;
}

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

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 20px;
  background: var(--bg);
}
.site-title {
  color: var(--muted);
  font-size: 16px;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.site-title:hover { color: var(--text); }

.menu-button {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 8px 7px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.menu-button span {
  display: block;
  height: 1.5px;
  background: var(--muted);
  border-radius: 1px;
}
.menu-button:hover { background: var(--panel); }

/* ---------- sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: min(320px, 85vw);
  background: var(--panel);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.sidebar-open .sidebar { transform: none; }
.sidebar-inner { padding: 22px 26px 40px; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(74, 66, 54, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-open .scrim { opacity: 1; pointer-events: auto; }

.sidebar-close {
  display: block;
  margin: -6px 0 14px -8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 28px/1 var(--font);
  cursor: pointer;
  padding: 4px 8px;
}
.sidebar-link {
  display: inline-block;
  margin-right: 18px;
  color: var(--muted);
  font-size: 15px;
  text-decoration: none;
}
.sidebar-link:hover { color: var(--text); }

.year h2 {
  margin: 30px 0 8px;
  font-size: 22px;
  font-weight: 500;
}
.year ul { list-style: none; margin: 0; padding: 0; }
.year li a {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  line-height: 1.4;
}
.year li a:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.year .d {
  flex: none;
  width: 3.2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.year li.current .t { color: var(--accent); }

/* ---------- post ---------- */

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.post-title {
  margin: 0 0 6px;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.25;
}
.post-date {
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.post-body h1,
.post-body h2 {
  margin: 2em 0 0.5em;
  font-size: 25px;
  font-weight: 500;
  line-height: 1.3;
}
.post-body h3 {
  margin: 1.6em 0 0.4em;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
}
.post-body h4 {
  margin: 1.4em 0 0.3em;
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
}
.post-body img { max-width: 100%; height: auto; border-radius: 6px; }
.post-body blockquote {
  margin: 1.5em 0;
  padding-left: 18px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-style: italic;
}
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.post-body code {
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
.post-body pre { background: var(--code-bg); padding: 14px; border-radius: 6px; overflow-x: auto; }
.post-body pre code { padding: 0; background: none; }
.post-body li { margin: 0.25em 0; }
.post-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 16px;
  display: block;
  overflow-x: auto;
}
.post-body th, .post-body td {
  border-bottom: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}
/* Hide the empty header row from "| | |" style tables */
.post-body th:empty { padding: 0; border: 0; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.post-nav a { color: var(--muted); text-decoration: none; }
.post-nav a:hover { color: var(--text); }
.post-nav .newer { text-align: right; }

@media (max-width: 520px) {
  body { font-size: 18px; }
  .post-title { font-size: 28px; }
}

/* ---------- pictures ---------- */

.post-body p > img:only-child,
.post-body p > img { display: block; margin: 1.6em auto 0.5em; }
/* An *italic line* directly under a picture becomes its caption */
.post-body p > img + em,
.post-body p > img + br + em {
  display: block;
  margin-bottom: 1.6em;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- charts & ratings ---------- */

.chart {
  margin: 1.8em 0;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}
.chart figcaption {
  margin-bottom: 10px;
  font-weight: 600;
}
.chart-row {
  display: grid;
  grid-template-columns: minmax(80px, 30%) 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.chart-label { line-height: 1.3; }
.chart-track {
  height: 10px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.chart-bar {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  opacity: 0.75;
}
.chart-value {
  min-width: 3.2em;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-average {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-weight: 600;
}
.chart-average .chart-bar { opacity: 1; }
.chart-average .chart-value { color: var(--text); }
