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

:root {
  --bg: #f4f1eb;
  --fg: #111;
  --fg-soft: #333;
  --muted: #777;
  --faint: #888;
  --faintest: #999;
  --border: #d0cdc6;
  --separator: #ccc;
  --link-underline: #d0cdc6;
  --link-hover: #777;
  --cursor-bg: #1a1a1a;
  --selection-bg: #1a1a1a;
  --selection-fg: #f4f1eb;
  --toggle-color: #bbb;
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --fg: #e0ddd6;
  --fg-soft: #b8b5ae;
  --muted: #888;
  --faint: #777;
  --faintest: #666;
  --border: #333;
  --separator: #444;
  --link-underline: #444;
  --link-hover: #aaa;
  --cursor-bg: #e0ddd6;
  --selection-bg: #e0ddd6;
  --selection-fg: #1a1a1a;
  --toggle-color: #666;
}

body {
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 4rem 1rem;
  line-height: 1.8;
  font-size: 16px;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s, color 0.15s;
}

a:hover {
  text-decoration-color: var(--link-hover);
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

.frame {
  width: 100%;
  max-width: 740px;
  border: 1px solid var(--border);
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 3rem;
  font-size: 0.75rem;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar nav {
  display: flex;
  gap: 0.5rem;
}

.topbar nav a {
  color: var(--faint);
  text-decoration: none;
  padding: 0.1rem 0.4rem;
}

.topbar nav a:hover {
  color: var(--fg);
}

.topbar nav a.active {
  color: var(--fg);
}

.topbar .site {
  color: var(--faintest);
  text-decoration: none;
}

.topbar .site:hover { color: var(--fg); }

.theme-toggle {
  background: none;
  border: none;
  color: var(--toggle-color);
  font-size: 0.85rem;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

.theme-toggle:hover {
  color: var(--fg);
}

.content {
  padding: 4rem 3rem 3rem;
}

/* Header */
header { margin-bottom: 2.5rem; }

h1 {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.4rem;
  font-style: italic;
}

.links {
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.links a { color: var(--muted); }
.links a:hover { color: var(--fg); }

.links a + a::before {
  content: '/';
  margin: 0 0.5rem;
  color: var(--separator);
  text-decoration: none;
  display: inline-block;
}

/* Sections */
section { margin-bottom: 2.5rem; }
section:last-child { margin-bottom: 0; }

h2 {
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--faint);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

section:first-of-type h2 {
  border-top: none;
  padding-top: 0;
}

/* Posts list */
.post {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
  gap: 1rem;
}

.post:hover .post-title { color: var(--muted); }

.post-title {
  font-size: 0.9rem;
  color: var(--fg);
  transition: color 0.15s;
}

.post-date {
  font-size: 0.75rem;
  color: var(--faintest);
  white-space: nowrap;
  flex-shrink: 0;
}

/* About */
.about p {
  font-size: 0.9rem;
  color: var(--fg-soft);
}

.about p + p { margin-top: 1.25rem; }

.info {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.info span + span::before {
  content: ',';
  margin-right: 0.3rem;
}

/* Cursor */
.cursor {
  display: inline-block;
  width: 0.55rem;
  height: 0.85em;
  background: var(--cursor-bg);
  vertical-align: middle;
  margin-left: 0.2rem;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* Status bar */
.statusbar {
  border-top: 1px solid var(--border);
  padding: 0.5rem 3rem;
  font-size: 0.65rem;
  color: var(--faintest);
  display: flex;
  justify-content: space-between;
}

.statusbar a {
  color: var(--faintest);
  text-decoration: none;
}

.statusbar a:hover {
  color: var(--fg);
}

.coming-soon {
  font-size: 0.85rem;
  color: var(--faintest);
  font-style: italic;
}

/* Post cards */
.post-cards {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.post-card {
  display: flex;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
}

.post-card:hover .post-card-title {
  color: var(--muted);
}

.post-thumb {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.post-card-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.post-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg);
  transition: color 0.15s;
}

.post-card-meta {
  font-size: 0.75rem;
  color: var(--faintest);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* Image fade-in */
img {
  opacity: 0;
  transition: opacity 0.4s ease;
}

img.loaded {
  opacity: 1;
}

/* Post page */
.post-hero {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--border);
}

.post-page h1 {
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.post-page .post-date {
  margin-bottom: 2rem;
}

.post-body p {
  font-size: 0.9rem;
  color: var(--fg-soft);
  margin-bottom: 1.25rem;
}

.post-body p:last-child {
  margin-bottom: 0;
}

.post-body ol,
.post-body ul {
  font-size: 0.9rem;
  color: var(--fg-soft);
  margin-bottom: 1.25rem;
  padding-left: 1.25rem;
}

.post-body li + li {
  margin-top: 0.4rem;
}

.post-body pre {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
}

.post-body pre code {
  font-family: inherit;
  font-size: inherit;
}

/* Newsletter */
.newsletter {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

section .newsletter {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.newsletter p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.newsletter form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.newsletter input[type="email"],
.newsletter input[type="submit"] {
  font-family: inherit;
  font-size: 0.8rem;
  line-height: normal;
  height: 2rem;
  padding: 0 0.6rem;
  border: 1px solid var(--border);
}

.newsletter input[type="email"] {
  background: var(--bg);
  color: var(--fg);
  width: 14rem;
  min-width: 0;
}

.newsletter input[type="email"]::placeholder {
  color: var(--faintest);
}

.newsletter input[type="email"]:focus {
  outline: none;
  border-color: var(--fg);
}

.newsletter input[type="submit"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  padding: 0 0.8rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.newsletter input[type="submit"]:hover {
  opacity: 0.8;
}

.newsletter input[type="submit"]:disabled {
  opacity: 0.5;
  cursor: default;
}

.newsletter .newsletter-msg {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.back-link {
  display: inline-block;
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  width: 100%;
}

.back-link:hover {
  color: var(--fg);
}

/* Lexicon list */
.lexicon-list {
  display: flex;
  flex-direction: column;
}

.lexicon-card {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.lexicon-card:last-child {
  border-bottom: none;
}

.lexicon-card-term {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg);
  transition: color 0.15s;
}

.lexicon-card:hover .lexicon-card-term {
  color: var(--muted);
}

.lexicon-card-summary {
  font-size: 0.8rem;
  color: var(--faintest);
  margin-top: 0.15rem;
}

/* Lexicon entry page */
.lexicon-body p {
  font-size: 0.9rem;
  color: var(--fg-soft);
  margin-bottom: 1.25rem;
}

.lexicon-body p:last-child {
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 480px) {
  body { padding: 1rem 0.5rem; }
  .topbar, .statusbar { padding-left: 1.25rem; padding-right: 1.25rem; }
  .content { padding: 2rem 1.25rem; }
  .post { flex-direction: column; gap: 0.1rem; }
  .post-card { flex-direction: column; }
  .post-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; }
}
