:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1a1e26;
  --panel-2: #222735;
  --text: #f5f7fb;
  --muted: #9aa4b3;
  --border: #2e3543;
  --accent: #8b5cf6;
  --accent-2: #7c3aed;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 19, 24, .94);
  backdrop-filter: blur(12px);
}

.brand {
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
}

.userbox {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--muted);
}

.userbox form { margin: 0; }

.shell {
  width: min(980px, calc(100% - 28px));
  margin: 34px auto 80px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

h1 {
  margin: 4px 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.auth-card {
  width: min(420px, 100%);
  margin: 80px auto;
  padding: 28px;
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input, textarea, button {
  font: inherit;
}

input, textarea {
  width: 100%;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}

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

input:focus, textarea:focus {
  border-color: var(--accent);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

button:hover { background: var(--accent-2); }

.linkbtn {
  background: transparent;
  padding: 0;
  color: var(--text);
}

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

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.flash.error {
  border-color: rgba(239, 68, 68, .7);
}

.new-topic {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
}

.topic-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.topic-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 17px 18px;
  text-decoration: none;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.topic-row:hover { background: var(--panel-2); }

.topic-meta {
  color: var(--muted);
  white-space: nowrap;
}

.back {
  color: var(--muted);
  text-decoration: none;
}

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

.message {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  font-weight: 900;
}

.message-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.message-head time {
  color: var(--muted);
  font-size: 12px;
}

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

.attachments {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.attachment {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 11px;
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.attachment span {
  color: var(--muted);
  white-space: nowrap;
}

.composer {
  position: sticky;
  bottom: 14px;
  margin-top: 24px;
  padding: 14px;
  box-shadow: 0 14px 50px rgba(0,0,0,.35);
}

.composer-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.composer-actions button {
  margin-left: auto;
}

.file-label {
  display: inline-flex;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  background: var(--panel-2);
}

.file-label input {
  display: none;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 650px) {
  .shell { width: min(100% - 18px, 980px); margin-top: 20px; }
  .topbar { padding: 0 12px; }
  .new-topic { grid-template-columns: 1fr; }
  .topic-row { align-items: flex-start; }
  .composer-actions { flex-wrap: wrap; }
  .composer-actions button { margin-left: 0; width: 100%; }
  .message-head { display: grid; gap: 0; }
}
