:root {
  --bg: #f8f4ee;
  --surface: #ffffff;
  --surface-alt: #fbf9f5;
  --text: #212121;
  --text-muted: #6f6a63;
  --text-faint: #a39d94;
  --border: #e6e0d6;
  --primary: #5f9b65;
  --primary-dark: #3f7445;
  --primary-tint: #e9f2ea;
  --flag: #b5502c;
  --flag-tint: #f8e8e1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --serif: "warnock-pro", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Gill Sans", "Gill Sans MT", GillSans, Calibri, "Trebuchet MS", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1918;
    --surface: #232221;
    --surface-alt: #2a2927;
    --text: #e9e6e1;
    --text-muted: #aaa49b;
    --text-faint: #7d786f;
    --border: #3a3836;
    --primary: #7dbb83;
    --primary-dark: #9fd2a4;
    --primary-tint: #26352a;
    --flag: #e88a66;
    --flag-tint: #3a2620;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

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

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

button { font: inherit; color: inherit; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  text-decoration: none !important;
}
.wordmark-lw {
  font-family: var(--serif);
  font-variant: small-caps;
  font-size: 1.45rem;
  letter-spacing: 0.06em;
}
/* The pun: "Sans AI" is set in sans-serif. */
.wordmark-sans {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 3px;
  padding: 1px 6px;
  position: relative;
  top: -2px;
}

.header-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.login-btn {
  border: 1px solid var(--border);
  background: none;
  border-radius: 3px;
  padding: 5px 12px;
  color: var(--text-muted);
  cursor: pointer;
}
.login-btn:hover { color: var(--text); border-color: var(--text-faint); }

.sans-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 16px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-size: 0.86rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.sans-banner svg { flex: none; }

/* ---------- Layout ---------- */

.layout {
  display: flex;
  justify-content: center;
  gap: 32px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.sidenav {
  flex: 0 0 210px;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  padding-top: 6px;
}
.nav-item {
  display: block;
  padding: 7px 10px;
  border-radius: 3px;
  color: var(--text);
  font-size: 1rem;
}
.nav-item:hover { background: var(--surface); text-decoration: none; }
.nav-item.small { font-size: 0.88rem; color: var(--text-muted); padding: 4px 10px 4px 22px; }
.nav-item.muted { color: var(--text-faint); }
.nav-sub { margin-bottom: 6px; }
.redacted {
  background: var(--text);
  color: transparent;
  border-radius: 2px;
  padding: 0 2px;
  user-select: none;
}
.solved {
  font-size: 0.72rem;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
}

.main { flex: 0 1 765px; min-width: 0; }

/* ---------- Front page ---------- */

.spotlight {
  display: block;
  padding: 28px 30px;
  margin-bottom: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none !important;
  background-image: radial-gradient(circle at 95% 15%, var(--primary-tint) 0, transparent 45%);
}
.spotlight:hover .spotlight-cta { text-decoration: underline; }
.spotlight-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.spotlight-title {
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1.15;
  margin: 6px 0 8px;
}
.spotlight-sub { font-family: var(--serif); font-size: 1.15rem; color: var(--text-muted); font-style: italic; }
.spotlight-cta { margin-top: 14px; color: var(--primary); }

.section { margin-bottom: 36px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.section-title {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.feed-tabs { display: flex; gap: 14px; font-size: 0.92rem; }
.feed-tab { color: var(--text-faint); cursor: pointer; }
.feed-tab.active { color: var(--text); border-bottom: 2px solid var(--primary); cursor: default; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
}
.filter-chip:hover { border-color: var(--text-faint); }
.chip-mode { font-size: 0.75rem; color: var(--text-faint); }
.filter-chip.mode-hidden { color: var(--text-faint); text-decoration: line-through; }
.filter-chip.mode-hidden .chip-mode { text-decoration: none; display: inline-block; }
.filter-chip.mode-boost .chip-mode,
.filter-chip.mode-required .chip-mode { color: var(--primary); font-weight: 600; }
.filter-chip.mode-required { border-color: var(--primary); }

.post-list { background: var(--surface); box-shadow: var(--shadow); }
.post-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.post-row:last-child { border-bottom: 0; }
.row-karma { flex: 0 0 34px; text-align: center; color: var(--text-muted); font-size: 0.95rem; }
.row-title { flex: 1 1 auto; min-width: 0; font-size: 1.07rem; }
.row-title a { color: var(--text); }
.row-icon { color: var(--text-faint); margin-right: 3px; position: relative; top: 2px; }
.row-icon.star { color: var(--primary); }
.event-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 5px;
  position: relative;
  top: -1px;
}
.row-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; font-size: 0.88rem; color: var(--text-muted); }
.row-author .user-link { color: var(--text-muted); }
.row-age { width: 26px; text-align: right; }
.row-comments { display: inline-flex; align-items: center; gap: 3px; color: var(--text-muted); min-width: 30px; }

.empty-state {
  padding: 28px 20px;
  background: var(--surface);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--serif);
  font-size: 1.1rem;
}
.empty-state strong { color: var(--text); }

.quick-takes { display: flex; flex-direction: column; gap: 10px; }
.quick-take { background: var(--surface); padding: 12px 16px; box-shadow: var(--shadow); }
.qt-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 0.9rem; }
.qt-body { font-family: var(--serif); font-size: 1.06rem; }
.qt-body p { margin: 6px 0 0; }

.recent { display: flex; flex-direction: column; gap: 10px; }
.recent-item { background: var(--surface); padding: 12px 16px; box-shadow: var(--shadow); }
.recent-post { font-size: 1rem; margin-bottom: 6px; }
.recent-post a { color: var(--text); font-weight: 600; }
.recent-comment { border-left: 2px solid var(--border); padding-left: 12px; }

.meta { color: var(--text-muted); font-size: 0.88rem; }
.user-link { color: var(--text); font-weight: 600; }

/* ---------- Votes, badges, toast ---------- */

.vote { display: inline-flex; align-items: center; gap: 2px; font-size: 0.88rem; color: var(--text-muted); }
.vote-btn {
  border: 0;
  background: none;
  padding: 0 3px;
  color: var(--text-faint);
  cursor: pointer;
  line-height: 1;
}
.vote-btn:hover { color: var(--primary); }
.vote.large { font-size: 1.6rem; gap: 10px; font-family: var(--serif); color: var(--text); }
.vote.large .vote-btn { font-size: 1.4rem; }

.autotag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.autotag-badge.flagged { background: var(--flag-tint); color: var(--flag); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  background: #2b2a28;
  color: #f4f1ec;
  border-radius: 4px;
  font-size: 0.95rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Post page ---------- */

.post { background: var(--surface); padding: 36px 48px 40px; box-shadow: var(--shadow); }

.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tag {
  font-size: 0.8rem;
  padding: 2px 9px;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.add-tag { cursor: pointer; }

.event-info { color: var(--primary); font-size: 0.95rem; margin-bottom: 4px; }

.post-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.6rem;
  line-height: 1.15;
  margin: 0 0 12px;
}
.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.post-meta .dot { color: var(--text-faint); }

.autotag-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 22px 0 6px;
  padding: 9px 12px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-size: 0.86rem;
  border-radius: 3px;
}
.autotag-note svg { flex: none; margin-top: 2px; }

.post-body {
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.6;
  margin-top: 22px;
}
.post-body p { margin: 0 0 1em; }
.post-body h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; margin: 1.6em 0 0.5em; }
.post-body h3 { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; margin: 1.4em 0 0.4em; }
.post-body ul, .post-body ol { padding-left: 1.4em; margin: 0 0 1em; }
.post-body li { margin-bottom: 0.4em; }
.post-body ol + ol { margin-top: -0.4em; }
.post-body blockquote {
  margin: 0 0 1em;
  padding: 2px 0 2px 20px;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}
.post-body blockquote p { margin: 0; }
.post-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }

.post-footer-vote { display: flex; justify-content: center; margin: 36px 0 12px; }

/* ---------- Comments ---------- */

.comments { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 22px; }
.comments-head { font-size: 1rem; color: var(--text-muted); margin-bottom: 14px; }
.comments-head .sort { color: var(--text); }

.new-comment, .reply-form { margin-bottom: 18px; }
.reply-form { margin: 8px 0 12px; }
textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--primary-tint); border-color: var(--primary); }
.form-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.submit-btn {
  border: 0;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  padding: 6px 16px;
  cursor: pointer;
}
.submit-btn:hover { background: var(--primary-dark); }
@media (prefers-color-scheme: dark) { .submit-btn { color: #14231a; } }
.link-btn { border: 0; background: none; padding: 0; color: var(--text-muted); cursor: pointer; font-size: 0.88rem; }
.link-btn:hover { color: var(--primary); }
.post-meta .link-btn { font-size: inherit; color: var(--primary); }

.comment {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 10px 14px 6px;
  margin-bottom: 10px;
  background: var(--surface);
}
.c-children .comment { margin: 10px 0 6px; }
.comment.depth-1 { background: var(--surface-alt); }
.comment.mine { border-color: var(--primary); }
.c-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 0.92rem; }
.c-body { font-family: var(--serif); font-size: 1.06rem; line-height: 1.5; }
.c-body p { margin: 6px 0; }
.comment.low > .c-body, .quick-take.low .qt-body { color: var(--text-muted); }
.c-actions { margin: 2px 0 4px; }
.agree { font-size: 0.82rem; color: var(--primary); }
.disagree { color: var(--text-faint); margin-left: 4px; }

.comment.collapsed { padding: 0; }
.collapsed-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}
.collapsed-line .meta { font-weight: 400; }
.caret { color: var(--text-faint); }
.collapse-reason { font-weight: 400; font-size: 0.82rem; color: var(--flag); }

.comment.typing { color: var(--text-muted); padding-bottom: 10px; }
.dots span { animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* ---------- User page ---------- */

.user-page { background: var(--surface); padding: 32px 40px; box-shadow: var(--shadow); }
.user-name { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; margin: 0 0 6px; }
.user-stats { display: flex; gap: 18px; color: var(--text-muted); margin-bottom: 14px; }
.user-bio { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 28px; }
.user-page .post-list, .user-page .recent-item { box-shadow: none; border: 1px solid var(--border); }
.user-page .recent-item { margin-bottom: 10px; }

/* ---------- Footer ---------- */

.site-footer {
  max-width: 765px;
  margin: 0 auto;
  padding: 0 16px 48px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--serif);
  font-size: 0.98rem;
}

/* ---------- Responsive ---------- */

.menu-btn { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidenav {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 250px;
    padding: 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 30;
    overflow-y: auto;
  }
  .sidenav.open { transform: none; box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12); }
  .layout { display: block; padding-top: 16px; }
}

@media (max-width: 600px) {
  .wordmark-lw { font-size: 1.2rem; }
  .sans-banner { font-size: 0.8rem; }
  .spotlight { padding: 20px; }
  .spotlight-title { font-size: 1.8rem; }
  .post-row { flex-wrap: wrap; row-gap: 4px; padding: 10px 12px; }
  .row-karma { flex-basis: 28px; }
  .row-title { flex-basis: calc(100% - 40px); }
  .row-meta { flex-basis: 100%; padding-left: 40px; }
  .post { padding: 22px 16px 28px; }
  .post-title { font-size: 1.9rem; }
  .post-body { font-size: 1.12rem; }
  .user-page { padding: 22px 16px; }
  .comment { padding: 8px 10px 4px; }
  .c-children .comment { margin-left: 0; }
}
