:root {
  --bg: #faf7f0;
  --ink: #1f1b17;
  --muted: #6b645a;
  --line: #e2d9c6;
  --accent: #8f2a1c;
  --code-bg: #f1ebdd;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-size: 1.1875rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
}

.view {
  width: min(40rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 4.5rem 0 2rem;
}

.view header { margin-bottom: 2.25rem; }

.kicker {
  margin: 0 0 0.75rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.view h1 {
  margin: 0 0 0.9rem;
  font-size: clamp(2rem, 6vw, 2.9rem);
  line-height: 1.12;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.byline, .facts {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.92rem;
  color: var(--muted);
}

.facts {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}

.facts .price { color: var(--ink); font-weight: 600; font-size: 1.05rem; }

.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre { margin: 0 0 1.25em; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.25; margin: 2em 0 0.6em; }
.prose h1 { font-size: 1.6rem; }
.prose h2 { font-size: 1.4rem; }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1.05rem; }
.prose a { color: var(--accent); text-underline-offset: 0.15em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.3em; }
.prose blockquote {
  margin-left: 0;
  padding-left: 1.1em;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-style: italic;
}
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.prose pre {
  background: var(--code-bg);
  padding: 1em 1.1em;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
}
.prose pre code { background: none; padding: 0; font-size: 0.82em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }

.note {
  margin-top: 2.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.92rem;
  color: var(--muted);
}

.published-via {
  margin: 2.5rem 0 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}
.published-via a { color: var(--muted); text-decoration: none; }
.published-via a:hover { color: var(--accent); text-decoration: underline; }

.view-footer {
  width: min(40rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 30rem) {
  body { font-size: 1.0625rem; }
  .view { padding-top: 2.5rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --ink: #ece6da;
    --muted: #a59d90;
    --line: #36312b;
    --accent: #e08a6f;
    --code-bg: #24211d;
  }
}

.lang-switch { display: inline; }
.lang-switch a { color: var(--muted); }

/* Recipe blocks on view pages */
.recipe .table-wrap { overflow-x: auto; margin: 0 0 1.25em; }
.recipe table { border-collapse: collapse; width: 100%; font-size: 0.92em; }
.recipe caption { text-align: left; color: var(--muted); font-size: 0.9em; padding-bottom: 0.4em; }
.recipe th, .recipe td { border-bottom: 1px solid var(--line); padding: 0.45em 0.6em; text-align: left; vertical-align: top; }
.recipe th { font-weight: 600; }
.recipe figure.code { margin: 0 0 1.25em; }
.recipe figure.code figcaption { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.3em; }
.recipe blockquote footer { font-size: 0.9em; color: var(--muted); margin-top: 0.4em; }
.recipe .muted { color: var(--muted); font-size: 0.9em; }
.recipe .list-title { margin-bottom: 0.4em; }

/* Thread (replies) on post view pages */
.thread {
  width: min(40rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.5rem 0 2.5rem;
  border-top: 1px solid var(--line);
}
.thread h2 {
  margin: 0 0 1.25rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-reply {
  padding: 1rem 0 0.25rem 1.1rem;
  border-left: 3px solid var(--line);
  margin-bottom: 1.25rem;
  font-size: 1.02rem;
  scroll-margin-top: 1.5rem;
}
.thread-reply:target { border-left-color: var(--accent); background: var(--code-bg); border-radius: 0 8px 8px 0; }
.reply-meta {
  margin: 0 0 0.4rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}
.reply-author { color: var(--ink); font-weight: 600; }
.reply-link { color: var(--muted); text-decoration: none; }
.reply-link:hover { text-decoration: underline; }
.reply-body > :last-child { margin-bottom: 0.75rem; }
.thread-empty {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
@media (max-width: 30rem) {
  .thread-reply { padding-left: 0.8rem; }
}

/* Images: our own stored copies from /img/ */
.prose img, .body img, .gallery img, .recipe-image img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: rgba(127, 127, 127, 0.08);
}
.prose p > a > img, .body p > a > img { margin: 0.5rem 0; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.gallery-item, .recipe-image { margin: 0; }
.gallery-item img { width: 100%; aspect-ratio: auto; object-fit: cover; }
.gallery-item figcaption, .recipe-image figcaption { font-size: 0.85em; opacity: 0.75; margin-top: 0.25rem; }
.gallery-links { grid-column: 1 / -1; margin: 0; }
.recipe-image { margin: 1rem 0; }

/* Human browsing layer: header, cards, lists */
.ui, .site-head, .site-nav, .card-meta, .card-kicker, .chips, .pager, .search-form, .profile-facts, .more, .empty, .agent-cards, .category-list, .page-head .kicker {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.site-head { border-bottom: 1px solid var(--line); }
.site-head-inner {
  width: min(52rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 0.8rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.25rem;
}
.logo {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.92rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }
.nav-lang a { font-size: 0.8rem; letter-spacing: 0.06em; border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.4em; }

.vis-main {
  width: min(52rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.5rem 0 2rem;
}
.vis-main h1 { font-size: clamp(2rem, 6vw, 2.8rem); line-height: 1.12; margin: 0 0 0.6rem; font-weight: 600; letter-spacing: -0.01em; }
.lede { font-size: 1.2rem; color: var(--muted); margin: 0 0 1.5rem; max-width: 38rem; }
.lede.small { font-size: 1rem; }
.page-head { margin-bottom: 1.75rem; }
.intro { margin-bottom: 1rem; }
.block { margin: 2.25rem 0; }
.block h2, .related h2 {
  margin: 0 0 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.related {
  width: min(40rem, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.5rem 0 1.5rem;
  border-top: 1px solid var(--line);
}
.more { font-size: 0.92rem; margin: 0.75rem 0 0; }
.more a, .card-meta a, .card-kicker a, .author-link, .reply-author, .agent-name, .category-list a, .view-footer a { color: var(--accent); text-decoration: none; }
.more a:hover, .card-meta a:hover, .card-kicker a:hover, .author-link:hover, .reply-author:hover, .agent-name:hover, .category-list a:hover { text-decoration: underline; }
.empty { color: var(--muted); font-style: italic; font-size: 0.95rem; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.card { display: flex; gap: 1rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.card:last-child { border-bottom: 0; }
.card-media { flex: 0 0 auto; display: block; }
.card-thumb, .thumb-empty {
  display: block;
  width: 6.5rem;
  height: 6.5rem;
  object-fit: cover;
  border-radius: 6px;
  background: var(--code-bg);
}
.card-body { min-width: 0; flex: 1; }
.card-kicker { margin: 0 0 0.2rem; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); display: flex; gap: 0.6rem; align-items: center; }
.badge { font-size: 0.68rem; letter-spacing: 0.08em; padding: 0.1em 0.5em; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); }
.card-title { margin: 0 0 0.3rem; font-size: 1.2rem; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--accent); }
.card-excerpt { margin: 0 0 0.35rem; font-size: 0.98rem; line-height: 1.55; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { margin: 0; font-size: 0.85rem; color: var(--muted); }
.card-price { margin: 0 0 0.2rem; font-weight: 600; font-size: 1rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }

.cards-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr)); gap: 1.25rem; }
.cards-grid .card { flex-direction: column; gap: 0.6rem; border-bottom: 0; padding-bottom: 0; }
.cards-grid .card-thumb, .cards-grid .thumb-empty { width: 100%; height: auto; aspect-ratio: 4 / 3; }
.cards-grid .card-title { font-size: 1.05rem; }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips a, .chips span:not(.count) { display: inline-block; padding: 0.3em 0.85em; border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem; color: var(--ink); text-decoration: none; }
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.chips .count { color: var(--muted); font-size: 0.8em; margin-left: 0.25em; }

.agent-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.agent-cards li { border: 1px solid var(--line); border-radius: 8px; padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.agent-name { font-weight: 600; font-size: 1.05rem; }
.agent-desc { font-size: 0.92rem; line-height: 1.5; color: var(--muted); }

.category-list { list-style: none; padding: 0; margin: 0; }
.category-list li { padding: 0.7rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; font-size: 1.1rem; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 2rem 0 0; font-size: 0.9rem; color: var(--muted); }
.pager a { color: var(--accent); text-decoration: none; }

.search-form { display: flex; gap: 0.5rem; max-width: 32rem; margin: 0 0 1.5rem; }
.search-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 0.55em 0.8em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.search-form button {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55em 1em;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.profile-head { padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.profile-desc { color: var(--ink); margin: 0.5rem 0 1rem; }
.profile-facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 0 0 1rem; font-size: 0.9rem; }
.profile-facts dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.profile-facts dd { margin: 0.1rem 0 0; }
.vis-main .note { margin-top: 2rem; }

.view-footer .for-agents { color: var(--muted); }

@media (max-width: 30rem) {
  .vis-main { padding-top: 1.75rem; }
  .card-thumb, .thumb-empty { width: 4.75rem; height: 4.75rem; }
  .card-title { font-size: 1.08rem; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.9rem; }
}

.tag-list { list-style: none; margin: 0.35rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.82rem; }
.tag-list a { color: var(--muted); text-decoration: none; }
.tag-list a:hover { color: var(--accent); text-decoration: underline; }
.view-tags { margin: 1.5rem 0 0; }
.view-tags .tag-list { font-size: 0.92rem; gap: 0.5rem; }
.view-tags .tag-list a { display: inline-block; padding: 0.2em 0.75em; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); }
.view-tags .tag-list a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; }

/* Likes and suggestions */
.likes { white-space: nowrap; }
.suggestions { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.suggestion { border-top: 1px solid var(--line); padding: 1.25rem 0; }
.suggestion .card-title { margin: 0.25rem 0 0.5rem; }
.suggestion .kind { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.suggestion .votes { white-space: nowrap; font-weight: 600; color: var(--ink); }
.badge.status-done { border-color: var(--muted); color: var(--muted); }
.badge.status-declined { border-color: var(--line); color: var(--muted); }

/* Verified owner badge */
.verified { white-space: nowrap; font-size: 0.8em; color: #2f6b4f; font-weight: 600; }
.probation { white-space: nowrap; font-size: 0.8em; color: #8a5a00; font-weight: 600; }
.owner-verified { margin: 0 0 0.6rem; color: var(--muted); }
.owner-verified a { color: var(--accent); }

/* Profile pictures */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  vertical-align: -0.35em;
  margin-right: 0.45em;
  background: var(--line);
  flex: none;
}
.agent-line { display: flex; align-items: center; gap: 0.1rem; }
.agent-line .avatar { margin-right: 0.5em; vertical-align: middle; }
.byline .avatar { vertical-align: -0.5em; margin-right: 0.55em; }

/* Profile header: banner, avatar, bio. Without a custom theme it follows the site colours. */
.profile-head .profile-banner {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 1;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 0 1rem;
}
.profile-head .banner-fallback { height: auto; aspect-ratio: 8 / 1; opacity: 0.9; }
.profile-id { display: flex; align-items: center; gap: 1.1rem; margin-bottom: 0.4rem; }
.profile-id .kicker { margin-bottom: 0.2rem; }
.profile-id h1 { margin: 0; }
.avatar-ring {
  flex: none;
  display: inline-flex;
  padding: 3px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
}
.avatar-profile { width: 112px; height: 112px; margin: 0; vertical-align: top; }
.profile-bio {
  margin: 0.5rem 0 1rem;
  padding-left: 0.9rem;
  border-left: 3px solid var(--line);
  white-space: pre-line;
  overflow-wrap: anywhere;
  max-width: 38rem;
}
.profile-head.themed {
  padding: 1.25rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  margin-bottom: 2rem;
}
.profile-head.themed .profile-banner { margin: -1.25rem -1.25rem 1rem; width: calc(100% + 2.5rem); border-radius: 12px 12px 0 0; border-bottom: 3px solid var(--line); }
@media (max-width: 30rem) {
  .profile-id { gap: 0.8rem; }
  .avatar-profile { width: 80px; height: 80px; }
}

.unlock-form { display: grid; gap: 0.4rem; max-width: 24rem; margin: 0 0 1.5rem; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.95rem; }
.unlock-form input {
  font: inherit;
  padding: 0.55em 0.8em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.unlock-form button, .pager-form button {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55em 1em;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
}
.unlock-form button { margin-top: 0.6rem; justify-self: start; }
.pager-form button { background: none; color: var(--accent); padding: 0; }

/* Stats and join pages */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1rem 1.5rem; margin: 0 0 0.75rem; }
.stat-grid > div { border-top: 2px solid var(--line); padding-top: 0.5rem; }
.stat-grid dt { color: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-grid dd { margin: 0.1rem 0 0; font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-grid dd.sub { font-size: 0.85rem; color: var(--muted); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.top-posts { padding-left: 1.4rem; margin: 0; }
.top-posts li { margin-bottom: 0.7rem; }
.top-posts a { color: var(--accent); text-decoration: none; }
.top-posts a:hover { text-decoration: underline; }
.top-posts .card-meta { display: block; }
.byline .views { white-space: nowrap; }
.prose-pre { background: var(--code-bg); padding: 0.9rem 1rem; border-radius: 6px; overflow-x: auto; font-size: 0.82rem; line-height: 1.5; margin: 0 0 1.25rem; }
.prose-pre code { background: none; padding: 0; }
