:root {
  --ink: #26362f;
  --page: #f5f4ee;
  --surface: #ffffff;
  --muted: #526157;
  --heading-accent: #397153;
  --link: #17634a;
  --border: #a6b4aa;
  --separator: #ced3cd;
  --focus: #26724a;
  --primary: #2d5942;
  --primary-hover: #244734;
  --on-primary: #ffffff;
  --hover: #dfe7e0;
  --danger: #754545;
  --danger-hover: #eee0e0;
  --depth-0: #f5f5f5;
  --depth-1: #f1f1f1;
  --depth-2: #ededed;
  --depth-3: #e9e9e9;
  --depth-4: #e5e5e5;

  font-size: 125%;
  --text-small: 0.9rem;
  --text-control: 0.95rem;
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5ebe7;
  --page: #171e1a;
  --surface: #222c26;
  --muted: #b4c4ba;
  --heading-accent: #95d5b0;
  --link: #9cddba;
  --border: #6d8174;
  --separator: #46574c;
  --focus: #a2e5bc;
  --primary: #a3d6b7;
  --primary-hover: #bae8cb;
  --on-primary: #142a1d;
  --hover: #354b3d;
  --danger: #f2baba;
  --danger-hover: #513737;
  --depth-0: #202923;
  --depth-1: #242e28;
  --depth-2: #28332c;
  --depth-3: #2c372f;
  --depth-4: #303c33;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
html.board-page {
  overflow-anchor: none;
  scrollbar-gutter: stable;
}
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 64px 24px 32px;
}
header {
  margin-bottom: 36px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--text-small);
  font-weight: 700;
  color: var(--muted);
}
h1 {
  font-size: clamp(2.3rem, 7.5vw, 3.8rem);
  letter-spacing: -0.06em;
  line-height: 1.1;
  margin: 12px 0 18px;
}
h1 span {
  color: var(--heading-accent);
}
header > p:last-child {
  color: var(--muted);
  line-height: 1.6;
}
h2 {
  font-size: 1.05rem;
  margin: 0 0 18px;
}
.composer {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  padding: 24px;
}
label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-control);
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  line-height: 1.6;
  color: inherit;
  background: var(--surface);
}
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.form-footer {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.form-footer p,
#sync-status,
.conversation-heading p,
footer {
  font-size: var(--text-small);
  color: var(--muted);
}
button {
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-size: var(--text-control);
  cursor: pointer;
  white-space: normal;
}
button:hover {
  background: var(--primary-hover);
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
#post-status {
  font-size: var(--text-control);
  margin: 14px 0 0;
}
#post-status:empty {
  display: none;
}
.conversation {
  margin-top: 36px;
}
.conversation-heading {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.conversation-heading h2,
.conversation-heading p {
  margin: 0;
}
#sync-status {
  margin: 6px 0 12px;
}
#empty-state {
  padding: 32px 0;
  color: var(--muted);
}
ol {
  padding: 0;
  list-style: none;
}
#messages {
  margin: 12px 0 0;
}
#messages > li {
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 10px;
}
#messages article {
  border-left: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
  padding-bottom: 12px;
  padding-left: 6px;
}
#messages .message-body {
  margin: 8px 0 0 6px;
  line-height: 1.55;
}
.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: var(--text-small);
  align-items: center;
}
.message-meta span {
  font-weight: 650;
}
time {
  color: var(--muted);
}
.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
  margin-bottom: 0;
}
footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
@media (max-width: 480px) {
  main {
    padding: 36px 16px 24px;
  }
  .composer {
    padding: 18px;
  }
  .form-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .form-footer p {
    margin: 0;
  }
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
nav > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
nav button {
  padding: 0.4rem 0.8rem;
}
a {
  color: var(--link);
  text-underline-offset: 0.2em;
}
input,
select {
  color: var(--ink);
  background: var(--surface);
}
input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.75rem;
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
label {
  display: block;
}
.author {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-avatar {
  width: 176px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}
[hidden] {
  display: none !important;
}
small {
  font-size: var(--text-small);
  font-weight: normal;
}
h1,
nav a {
  overflow-wrap: anywhere;
}
nav > div {
  min-width: 0;
}

.message-meta .avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.replies {
  margin: 4px 0 0 16px;
  padding: 0;
  border-radius: 8px;
}
.replies > li {
  padding: 0;
}
.replies > li > article {
  padding: 6px 6px 12px;
}
.message {
  background: var(--depth-4);
}
.message[data-depth="0"] {
  background: var(--depth-0);
}
.message[data-depth="1"] {
  background: var(--depth-1);
}
.message[data-depth="2"] {
  background: var(--depth-2);
}
.message[data-depth="3"] {
  background: var(--depth-3);
}
.replies .replies .replies .replies .replies {
  margin-left: 0;
}
.message-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px 8px;
  margin: 18px 0 0 6px;
}
.message-actions button {
  margin: 0;
  padding: 4px 6px;
  min-width: 44px;
  min-height: 32px;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-small);
  line-height: 1.35;
  border-radius: 4px;
}
.message-actions .reply-button {
  margin-right: auto;
  color: var(--link);
}
.message-actions .delete-button,
.message-actions .moderate-button {
  color: var(--danger);
}
.message-actions button:hover {
  background: var(--hover);
}
.message-actions .delete-button:hover,
.message-actions .moderate-button:hover {
  background: var(--danger-hover);
}
#cancel-reply {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--link);
  padding: 0.4rem 0.75rem;
}
#cancel-reply:hover {
  background: var(--hover);
}
.message-meta .reply-parent {
  margin: 0;
  font-size: var(--text-small);
  font-weight: 400;
  white-space: nowrap;
}
.reply-parent a {
  color: var(--muted);
}
.reply-composer {
  margin: 8px 0;
}
#reply-context {
  padding: 0.75rem;
  background: var(--depth-0);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}
#reply-context p {
  margin: 0;
  overflow-wrap: anywhere;
}
#cancel-reply {
  margin-top: 0.5rem;
}
li[id] {
  scroll-margin-top: 1.5rem;
}
li:target > article {
  background: var(--hover);
  border-radius: 6px;
}
@media (max-width: 480px) {
  .replies .replies .replies {
    margin-left: 0;
  }
}

.conversation-controls {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  align-items: center;
  gap: 6px;
}
.conversation-controls label {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-small);
}
#root-order {
  max-width: 100%;
  font: inherit;
  font-size: var(--text-small);
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
}
#reply-order-help {
  font-size: var(--text-small);
  color: var(--muted);
  margin: 6px 0 0;
}

.message.is-deleted > article > .message-body {
  color: var(--muted);
  font-style: italic;
}
#delete-status {
  margin: 0 0 8px;
  font-size: var(--text-small);
}
#delete-status:empty {
  display: none;
}

.board-navigation {
  margin-block: 1.5rem;
}
.board-navigation select {
  max-width: 100%;
  font: inherit;
  padding: 0.5rem;
  margin-block-start: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.board-navigation details {
  margin-block-start: 0.75rem;
}
.board-navigation input,
select {
  color: var(--ink);
  background: var(--surface);
}
input {
  max-width: 100%;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.review-actions button {
  padding: 6px 10px;
  min-height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-small);
  line-height: 1.35;
}
.review-actions button[value="remove"] {
  border-color: var(--border);
  color: var(--danger);
}
.review-actions button:hover {
  background: var(--hover);
}
@media (pointer: coarse) {
  .message-actions button,
  .review-actions button {
    min-height: 44px;
  }
}

#sync-status:empty {
  display: none;
}
#submit-help {
  color: var(--muted);
  font-size: var(--text-small);
  margin-bottom: 0;
}
.reply-button svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
}
.message-actions .reply-button,
.message-actions .more-button {
  min-height: 44px;
}
.message-actions .more-button {
  font-size: 1.4rem;
  line-height: 1;
}
.message-overflow {
  position: relative;
}
.message-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 2;
  min-width: min(7rem, 70vw);
  max-width: min(14rem, 70vw);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 15%);
}
.message-menu button {
  width: 100%;
  text-align: left;
  min-height: 44px;
}
#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}
#theme-toggle:hover,
#theme-toggle[aria-pressed="true"] {
  background: var(--hover);
}
