:root {
  --bg: #f9f6f0;
  --surface: #fdfbf6;
  --text: #332e28;
  --heading: #4a4339;
  --muted: #7d7466;
  --muted-2: #6b6155;
  --line: #ddd6c9;
  --line-strong: #c9b99a;
  --chip: #e8e2d6;
  --chip-hover: #d8d2c6;
  --chip-soft: #ece5d8;
  --hover-bg: #f1ebe0;
  --brand: #723f1c;
  --link: #8b4513;
  --link-hover: #654321;
  --accent: #9a7b4f;
  --accent-hover: #7d6340;
  --on-accent: #f9f6f0;
  --initial: #6b5a42;
  --ok: #4f6b3a;
  --danger: #8a3b2e;
  --danger-hover: #6e2e24;
  --banner: #f3e2b8;
  --banner-line: #d9c38c;
  --shadow: rgba(0, 0, 0, 0.12);
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1814;
    --surface: #24201b;
    --text: #e6dfd3;
    --heading: #d8cebd;
    --muted: #a39887;
    --muted-2: #a89d8b;
    --line: #3a342b;
    --line-strong: #5a4f40;
    --chip: #322c25;
    --chip-hover: #40382f;
    --chip-soft: #2e2822;
    --hover-bg: #2a251f;
    --brand: #c98a55;
    --link: #d9a066;
    --link-hover: #ebbd8c;
    --accent: #9a7b4f;
    --accent-hover: #b08f5f;
    --on-accent: #fbf7f0;
    --initial: #d0c0a5;
    --ok: #8fb07a;
    --danger: #a5493a;
    --danger-hover: #c0584a;
    --banner: #4a3d1f;
    --banner-line: #6b5a2e;
    --shadow: rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  margin: 0;
  padding: 0;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  padding: 1rem 0;
  margin-bottom: 2rem;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 1.25rem);
  text-decoration: none;
  color: var(--brand);
}

.site-brand:hover {
  color: var(--brand);
  text-decoration: none;
}

.site-brand picture {
  display: flex;
  flex-shrink: 0;
}

.site-logo {
  width: clamp(60px, 13vw, 104px);
  height: auto;
  flex-shrink: 0;
}

.site-title {
  font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  font-size: clamp(1rem, 6vw, 2.9rem);
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.site-header nav > ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 2.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
  letter-spacing: 0.02em;
}

/* Masthead (wide screens) */
@media (min-width: 601px) {
  .site-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0.5rem;
  }

  .header-top {
    justify-content: center;
  }

  .site-header nav {
    margin-top: 1.25rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .site-header nav > ul {
    justify-content: center;
    padding: 0.7rem 0;
  }
}

.site-header nav li {
  margin: 0;
}

.site-header nav a {
  text-decoration: none;
  white-space: nowrap;
  color: var(--text);
}

.site-header nav a:hover {
  text-decoration: underline;
}

/* Dropdowns (.open added by js/main.js) */
.site-header nav .dropdown {
  position: relative;
}

.site-header nav .dropdown-toggle {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.site-header nav .dropdown-toggle::after {
  content: " \25BE";
  font-size: 0.8em;
}

.site-header nav .dropdown-toggle:hover {
  text-decoration: underline;
}

.site-header nav .dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  min-width: 170px;
  background-color: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 6px 14px var(--shadow);
  z-index: 10;
}

.site-header nav .dropdown.open .dropdown-content {
  display: flex;
}

@media (hover: hover) and (min-width: 601px) {
  .site-header nav .dropdown:hover .dropdown-content {
    display: flex;
  }
}

.site-header nav .dropdown-content li {
  margin: 0;
}

.site-header nav .dropdown-content a {
  display: block;
  padding: 0.4rem 1rem;
}

.site-header nav .dropdown-content a:hover {
  background-color: var(--line);
  text-decoration: none;
}

@media (max-width: 600px) {
  .site-title { letter-spacing: 0.04em; }
  .container { padding: 1rem; }

  .menu-toggle { display: block; }

  .site-header nav { display: none; }
  .site-header.menu-open nav { display: block; }

  .site-header nav > ul {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .site-header nav li {
    margin-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .site-header nav li:last-child {
    border-bottom: none;
  }

  .site-header nav a,
  .site-header nav .dropdown-toggle {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.6rem 0.25rem;
  }

  .site-header nav .dropdown-content {
    position: static;
    min-width: 0;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--line);
    margin: 0 0 0.5rem 0.75rem;
    padding: 0;
  }

  .site-header nav .dropdown-content li {
    border-bottom: none;
  }

  .site-header nav .dropdown-content a {
    padding: 0.45rem 0.75rem;
  }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1rem;
  margin-top: 3rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.footer-legal {
  font-size: 0.85rem;
}

.footer-legal a {
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

/* RSS page (feed.xsl) */
.feed-note {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.feed-note code {
  word-break: break-all;
}

/* Content */
.essay-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

h1 {
  margin-bottom: 0.5rem;
  font-weight: 700;
  font-size: 1.8rem;
  line-height: 1.3;
}

h2 {
  margin-top: 2rem;
  font-weight: 600;
  color: var(--heading);
  font-size: 1.5rem;
}

h3 {
  margin-top: 1.5rem;
  font-weight: 600;
  color: var(--heading);
  font-size: 1.25rem;
}

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

.essay-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.reading-time::before {
  content: "·";
  margin: 0 0.4rem;
}

.tags {
  display: inline-block;
  margin-left: 1rem;
}

.tags a {
  background-color: var(--chip);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.8rem;
  margin-right: 0.5rem;
  color: var(--text);
}

.tags a:hover {
  background-color: var(--chip-hover);
}

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

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

.essay-content {
  margin: 2rem 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.7;
}

.essay-content h2,
.essay-content h3 {
  font-family: var(--serif);
}

.essay-content h2 {
  margin-top: 2rem;
}

.essay-content blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  border-left: 3px solid var(--line-strong);
  color: var(--heading);
  font-style: italic;
}

.essay-content img {
  max-width: 100%;
  height: auto;
}

/* Post footer */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.writer-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.writer-card p {
  margin: 0;
}

.writer-card .writer-card-name {
  font-weight: bold;
  color: var(--text);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.post-nav a {
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
}

.post-nav a:hover {
  background: var(--hover-bg);
  text-decoration: none;
}

.post-nav .label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-nav .next {
  grid-column: 2;
  text-align: right;
}

.more-on-tag h3 {
  margin-bottom: 0.5rem;
}

.more-on-tag ul {
  padding-left: 1.25rem;
  margin: 0;
}

@media (max-width: 600px) {
  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav .next {
    grid-column: 1;
  }
}

/* Lists */
.essay-list, .tag-list {
  list-style: none;
  padding: 0;
}

.essay-list li, .tag-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.essay-list li:last-child, .tag-list li:last-child {
  border-bottom: none;
}

.button-link {
  display: inline-block;
  padding: 0.55rem 1.4rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 5px;
  font-weight: bold;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
  text-decoration: none;
}

/* Placeholders */
.placeholder {
  border: 2px dashed var(--line-strong);
  background-color: var(--surface);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  color: var(--muted-2);
}

.placeholder-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.placeholder h3 {
  margin: 0.25rem 0;
  color: var(--text);
}

.placeholder p {
  margin: 0.25rem 0 0 0;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem 0;
}

.template-grid .placeholder {
  margin: 0;
}

.card-link {
  text-decoration: none;
  color: inherit;
}

.card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  height: 100%;
}

.card-link:hover .card {
  background-color: var(--hover-bg);
}

.section-kicker {
  margin-top: -0.5rem;
  color: var(--accent);
  font-size: 0.9rem;
}

.empty-note,
.byline {
  color: var(--muted-2);
  font-style: italic;
}

/* Cover photo */
.cover-image {
  display: block;
  max-width: 100%;
  max-height: 420px;
  width: auto;
  height: auto;
  margin: 1rem auto;
  border-radius: 6px;
}

/* Latest Posts rows */
.news-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.news-cover {
  width: 140px;
  height: 95px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.news-title {
  font-weight: bold;
  font-size: 1.1rem;
}

.news-subtitle,
.news-meta {
  margin: 0.15rem 0 0 0;
}

.news-meta {
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .news-item {
    flex-direction: column;
  }

  .news-cover {
    width: 100%;
    height: 180px;
  }
}

/* Writer pages */
.writer-photo {
  max-width: 220px;
  border-radius: 6px;
  margin: 0.5rem 0 1rem 0;
}

.writer-intro {
  margin-bottom: 2rem;
}

/* Forms */
.comment-form {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: inherit;
  background-color: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

form button[type="submit"] {
  padding: 0.5rem 1.5rem;
  font: inherit;
  font-weight: bold;
  color: var(--on-accent);
  background-color: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

form button[type="submit"]:hover {
  background-color: var(--accent-hover);
}

.comment-notice {
  font-size: 0.9rem;
  color: var(--muted-2);
}

/* Reader comments */
.approved-comments {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.approved-comment {
  background-color: var(--surface);
  border-left: 3px solid var(--line-strong);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.approved-comment p {
  margin: 0.25rem 0;
  white-space: pre-line;
}

.approved-comment-meta {
  font-size: 0.9rem;
  color: var(--muted-2);
}

.approved-comments + .comment-form {
  margin-top: 1.5rem;
}

.comment-sent {
  color: var(--ok);
  font-weight: bold;
}

/* Unused photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; margin: 0.8rem 0; }
.photo-item { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; word-break: break-all; cursor: pointer; }
.photo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }

.draft-banner {
  background: var(--banner);
  border: 1px solid var(--banner-line);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
}

/* Comment moderation */
.moderation .moderation-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.moderation button {
  padding: 0.4rem 1rem;
  font: inherit;
  font-weight: bold;
  color: var(--on-accent);
  background-color: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.moderation .btn-delete {
  background-color: var(--danger);
}

.moderation .btn-delete:hover {
  background-color: var(--danger-hover);
}

.moderation button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Avatars, topic chips */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 1px solid var(--line);
}

.avatar-sm {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.avatar-lg {
  width: 96px;
  height: 96px;
}

.avatar-md {
  width: 64px;
  height: 64px;
}

.avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  color: var(--initial);
  font-weight: bold;
  font-size: 1.1rem;
}

.avatar-sm.avatar-initial {
  font-size: 0.7rem;
}

.avatar-md.avatar-initial {
  font-size: 1.6rem;
}

.post-author {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 0.2rem;
  color: inherit;
  text-decoration: none;
  font-weight: bold;
}

.post-author:hover {
  color: inherit;
  text-decoration: none;
}

.post-author:hover .post-author-name {
  text-decoration: underline;
}

.byline-author {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.byline-author:hover {
  text-decoration: underline;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1rem;
}

.profile-header h1 {
  margin: 0;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 2rem;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}

.topic-chip:hover {
  background: var(--line);
  text-decoration: none;
}

.topic-chip .count {
  font-size: 0.8rem;
  background: var(--chip-soft);
  border-radius: 999px;
  padding: 0 0.45rem;
}

.topic-chip.empty {
  opacity: 0.55;
}

.post-author + .essay-meta {
  margin-top: 0.15rem;
}

/* The Record */
.record-intro { color: var(--muted); font-style: italic; margin-top: -0.5rem; }
.record-month-label {
  font-size: 0.95rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2);
  border-bottom: 1px solid var(--line-strong); padding-bottom: 0.3rem; margin: 2.2rem 0 0.4rem;
}
.record-entry { display: flex; gap: 1.2rem; padding: 1.2rem 0; border-bottom: 1px solid var(--line); }
.record-date { flex: 0 0 4.2rem; font-family: var(--serif); color: var(--brand); font-weight: 600; padding-top: 0.15rem; }
.record-body { flex: 1; min-width: 0; }
.record-title { margin: 0 0 0.6rem; font-size: 1.15rem; line-height: 1.35; color: var(--heading); }
.record-shot { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 0.6rem; }
.record-shot-empty {
  height: 9rem; display: flex; align-items: center; justify-content: center;
  border-style: dashed; color: var(--muted); background: var(--surface); font-size: 0.9rem;
}
.record-why p { margin: 0 0 0.5rem; }
.record-links { font-size: 0.9rem; color: var(--muted); margin: 0; }
.record-tag { background: var(--chip); border-radius: 3px; padding: 0.05rem 0.4rem; font-size: 0.8rem; }
@media (max-width: 600px) {
  .record-entry { flex-direction: column; gap: 0.3rem; }
  .record-date { flex: none; }
}

/* Derailments */
.derail { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.derail-meta { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.3rem; }
.derail-title { margin: 0 0 0.5rem; font-size: 1.1rem; line-height: 1.35; color: var(--heading); }
.derail-img { display: block; max-width: 100%; border-radius: 4px; margin-bottom: 0.6rem; }
.derail-body p { margin: 0 0 0.5rem; }
.derail-link { font-size: 0.9rem; margin: 0; }
.home-derailments { margin-top: 2.5rem; }
.see-all { margin-top: 1rem; }
