:root {
  --bg: #f7f1e3;
  --bg-soft: #fffaf2;
  --panel: rgba(255, 252, 247, 0.92);
  --panel-strong: #fffdf8;
  --ink: #241911;
  --muted: #70584a;
  --line: rgba(77, 47, 31, 0.15);
  --accent: #d95d39;
  --accent-strong: #b8401e;
  --accent-soft: rgba(217, 93, 57, 0.14);
  --danger: #9e2c2c;
  --danger-soft: rgba(158, 44, 44, 0.14);
  --ok: #2f7d5a;
  --shadow: 0 18px 48px rgba(73, 38, 19, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 176, 104, 0.42), transparent 30%),
    radial-gradient(circle at top right, rgba(214, 91, 57, 0.18), transparent 26%),
    linear-gradient(180deg, #fff8ee 0%, var(--bg) 55%, #f0e4d5 100%);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.narrow-shell {
  width: min(760px, calc(100% - 32px));
}

.hero-card,
.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.hero-card {
  border-radius: calc(var(--radius) + 4px);
  padding: 28px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  animation: rise-in 320ms ease-out;
}

.compact-hero {
  padding: 24px 28px;
}

.hero-card h1,
.panel h2,
.side-note h3 {
  font-family: "Gill Sans", "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  letter-spacing: 0.02em;
}

.hero-card h1 {
  margin: 6px 0 10px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.95;
}

.hero-copy,
.panel p,
.subtle,
.form-hint,
.composer-bar p,
.info-list dt {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--accent-strong);
}

.hero-badge {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff6d7, #ffd5b6);
  color: var(--accent-strong);
  border: 1px solid rgba(217, 93, 57, 0.24);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notice {
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.notice-success {
  background: rgba(47, 125, 90, 0.1);
  border-color: rgba(47, 125, 90, 0.22);
}

.notice-error,
.notice-warning {
  background: rgba(158, 44, 44, 0.08);
  border-color: rgba(158, 44, 44, 0.18);
}

.notice-links {
  margin-top: 10px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.join-panel {
  display: grid;
  gap: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 700;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  padding: 14px 16px;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(217, 93, 57, 0.5);
  box-shadow: 0 0 0 4px rgba(217, 93, 57, 0.12);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 24px rgba(217, 93, 57, 0.22);
}

.button-secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border-color: var(--line);
}

.button-danger {
  color: #fff;
  background: linear-gradient(135deg, #b94a4a, var(--danger));
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.chat-grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 20px;
}

.chat-panel,
.side-panel {
  min-height: 0;
}

.chat-panel-header,
.panel-heading,
.composer-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.messages,
.admin-feed {
  display: grid;
  gap: 12px;
}

.messages {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
  margin: 18px 0;
}

.message {
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid rgba(217, 93, 57, 0.08);
  animation: rise-in 240ms ease-out;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.message p {
  margin: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
}

.message-body {
  line-height: 1.6;
  word-break: break-word;
}

.message-body > :first-child {
  margin-top: 0;
}

.message-body > :last-child {
  margin-bottom: 0;
}

.message-body p,
.message-body div,
.message-body ul,
.message-body ol,
.message-body blockquote {
  margin: 0 0 10px;
}

.message-body a {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
}

.message-body blockquote {
  padding-left: 14px;
  border-left: 3px solid rgba(217, 93, 57, 0.28);
  color: var(--muted);
}

.editor-shell {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(77, 47, 31, 0.08);
  background: rgba(255, 248, 238, 0.92);
}

.toolbar-button {
  min-height: 36px;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(77, 47, 31, 0.12);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.toolbar-button:hover {
  border-color: rgba(217, 93, 57, 0.32);
}

.toolbar-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rich-editor {
  min-height: 140px;
  padding: 14px 16px;
  outline: none;
}

.rich-editor:focus {
  box-shadow: inset 0 0 0 3px rgba(217, 93, 57, 0.12);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: rgba(112, 88, 74, 0.7);
}

.rich-editor[contenteditable="false"] {
  background: rgba(240, 232, 223, 0.8);
  color: rgba(36, 25, 17, 0.65);
}

.rich-editor p,
.rich-editor div,
.rich-editor ul,
.rich-editor ol,
.rich-editor blockquote {
  margin: 0 0 10px;
}

.composer {
  display: grid;
  gap: 12px;
}

.form-error {
  color: var(--danger);
}

.info-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

.info-list div {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(77, 47, 31, 0.08);
}

.info-list dt {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.info-list dd {
  margin: 0;
  font-weight: 700;
}

.side-note {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 247, 224, 0.88), rgba(255, 235, 224, 0.82));
}

.side-note ul,
.checklist ul {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  border-radius: 20px;
  padding: 18px 20px;
  display: grid;
  gap: 8px;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid rgba(77, 47, 31, 0.08);
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status-live {
  background: rgba(47, 125, 90, 0.12);
  color: var(--ok);
}

.status-idle {
  background: rgba(112, 88, 74, 0.12);
  color: var(--muted);
}

.status-banned {
  background: var(--danger-soft);
  color: var(--danger);
}

.inline-form {
  margin: 0;
}

.admin-feed {
  max-height: 880px;
  overflow-y: auto;
  padding-right: 4px;
}

.admin-message {
  background: rgba(255, 255, 255, 0.74);
}

.admin-message-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

a {
  color: var(--accent-strong);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .chat-grid,
  .admin-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-table {
    min-width: 640px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding: 20px 0 32px;
  }

  .hero-card,
  .panel,
  .stat-card {
    border-radius: 18px;
  }

  .hero-card,
  .chat-panel-header,
  .panel-heading,
  .composer-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .messages,
  .admin-feed {
    max-height: none;
  }
}
