:root {
  --bg: #fdc114;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.85);
  --rule: rgba(255, 255, 255, 0.5);
  --code-bg: rgba(0, 0, 0, 0.15);
  --btn-bg: rgba(0, 0, 0, 0.12);
  --btn-border: rgba(255, 255, 255, 0.6);
  --accent: #ffffff;

  --font: 'VT323', monospace;
  --base-size: 22px;
  --line-height: 1.4;
  --measure: 640px;
}

[data-theme="dark"] {
  --bg: #111111;
  --fg: #e8e8e8;
  --muted: rgba(232, 232, 232, 0.7);
  --rule: rgba(232, 232, 232, 0.25);
  --code-bg: rgba(255, 255, 255, 0.08);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-border: rgba(232, 232, 232, 0.4);
  --accent: #fdc114;
}

[data-theme="sepia"] {
  --bg: #f4ecd8;
  --fg: #5b4636;
  --muted: rgba(91, 70, 54, 0.75);
  --rule: rgba(91, 70, 54, 0.3);
  --code-bg: rgba(91, 70, 54, 0.12);
  --btn-bg: rgba(91, 70, 54, 0.08);
  --btn-border: rgba(91, 70, 54, 0.4);
  --accent: #b07b3a;
}

[data-font="serif"] {
  --font: 'Lora', Georgia, 'Times New Roman', serif;
  --base-size: 18px;
  --line-height: 1.65;
  --measure: 680px;
}

[data-font="plex-serif"] {
  --font: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  --base-size: 18px;
  --line-height: 1.65;
  --measure: 680px;
}

[data-font="sans"] {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --base-size: 17px;
  --line-height: 1.6;
  --measure: 680px;
}

[data-font="ubuntu"] {
  --font: 'Ubuntu', system-ui, sans-serif;
  --base-size: 17px;
  --line-height: 1.6;
  --measure: 680px;
}

[data-font="atkinson"] {
  --font: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --base-size: 17px;
  --line-height: 1.6;
  --measure: 680px;
}

body {
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page {
  transition: font-size 0.2s ease;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  margin: 0;
}

.page {
  max-width: var(--measure);
  margin: 60px auto;
  padding: 0 24px;
  font-size: var(--base-size);
  line-height: var(--line-height);
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-weight: normal;
  font-size: 2.2em;
  margin: 8px 0 16px;
  flex: 1 1 auto;
  line-height: 1.1;
}

.back-link {
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9em;
  opacity: 0.85;
}

.back-link:hover { opacity: 1; }

.reader-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
  font-size: 0.85em;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  overflow: hidden;
}

.seg button {
  font-family: inherit;
  font-size: inherit;
  background: transparent;
  color: var(--fg);
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1.2;
}

.seg button + button {
  border-left: 1px solid var(--btn-border);
}

.seg button.active,
.seg button:hover {
  background: var(--btn-bg);
}

.topic {
  margin: 0 0 28px;
}

.topic-title {
  font-size: 0.95em;
  font-weight: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px dashed var(--rule);
}

.site-footer {
  max-width: var(--measure);
  margin: 32px auto 40px;
  padding: 16px 24px 0;
  border-top: 1px dashed var(--rule);
  text-align: center;
  font-size: 0.8em;
  color: var(--muted);
}

.site-footer a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.site-footer a:hover { text-decoration-style: solid; }

.post h1, .post h2, .post h3 {
  font-weight: normal;
  line-height: 1.2;
  margin: 1.4em 0 0.4em;
}

.post h2 { font-size: 1.4em; }
.post h3 { font-size: 1.15em; }

.post ul, .post ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}

.post a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.post a:hover { text-decoration-style: solid; }

.post blockquote {
  margin: 0 0 1em;
  padding: 0.4em 0 0.4em 14px;
  border-left: 3px solid var(--btn-border);
  color: var(--muted);
}

.post pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.92em;
  margin: 0 0 1em;
}

.post pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

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

.post-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule);
}

.post-list a {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--fg);
  text-decoration: none;
}

.post-list a:hover .post-title {
  border-bottom: 2px solid var(--accent);
}

.post-date {
  opacity: 0.85;
  font-size: 0.85em;
  color: var(--muted);
}

.post p {
  margin: 0 0 1em;
}

.post code {
  background: var(--code-bg);
  padding: 0 4px;
  border-radius: 3px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 0.92em;
}

@media (max-width: 600px) {
  .page { margin: 30px auto; }
  .page-header h1 { font-size: 1.7em; }
}
