:root {
  color-scheme: light;
  --bg: #eef2df;
  --paper: #f8f3df;
  --paper-strong: #fff8e6;
  --line: #cbbf9e;
  --ink: #2f241c;
  --muted: #716957;
  --accent: #7f1d1d;
  --accent-hover: #611717;
  --blue: #243b78;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Tahoma, sans-serif;
  font-size: 15px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #d8dfc1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account {
  overflow: hidden;
  max-width: 180px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand,
.back,
.link-button,
.tab {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.link-button {
  font-size: 13px;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.status.online {
  color: #1f6f35;
}

.status.offline {
  color: #9b1c1c;
}

.layout {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 16px;
}

.section-head,
.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.room-head {
  justify-content: flex-start;
}

.tabs {
  display: flex;
  border: 1px solid var(--line);
}

.tab {
  min-height: 34px;
  padding: 6px 12px;
}

.tab.active {
  background: var(--accent);
  color: white;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--accent);
  font-size: 22px;
}

.room-head p,
.rooms p {
  color: var(--muted);
  font-size: 13px;
}

.primary {
  min-height: 36px;
  border: 1px solid var(--accent-hover);
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-hover);
}

.create-form,
.message-form,
.auth-form {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-form {
  max-width: 520px;
}

.create-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) auto;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.form-message {
  min-height: 20px;
  color: var(--accent);
  overflow-wrap: anywhere;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--ink);
  padding: 9px 10px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.rooms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.room-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 10px;
  min-height: 100px;
  border: 1px solid var(--line);
  background: var(--paper-strong);
  padding: 8px;
  cursor: pointer;
}

.room-card:hover h2 {
  color: var(--blue);
  text-decoration: underline;
}

.room-card img {
  width: 84px;
  height: 84px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #ddd;
}

.room-card h2 {
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: 16px;
  margin-bottom: 8px;
}

.thread {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.post {
  width: fit-content;
  max-width: min(760px, 100%);
  border: 1px solid var(--line);
  background: var(--paper-strong);
  padding: 9px 11px;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.post-meta img {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.post-body {
  margin-top: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post-body a {
  color: var(--blue);
}

.post-image {
  display: block;
  width: min(420px, 100%);
  max-height: 320px;
  margin-top: 8px;
  border: 1px solid var(--line);
  object-fit: contain;
  background: #eee;
}

.hidden {
  display: none;
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    padding: 12px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .create-form {
    grid-template-columns: 1fr;
  }

  .room-card {
    grid-template-columns: 72px 1fr;
  }

  .room-card img {
    width: 72px;
    height: 72px;
  }
}
