:root {
  --bg: #0f1419;
  --panel: #16181c;
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-dim: rgba(29, 155, 240, 0.15);
  --danger: #f4212e;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: minmax(140px, 22%) minmax(180px, 28%) 1fr;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  max-height: 100dvh;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  .panel-cats,
  .panel-topics {
    max-height: 40vh;
    border-bottom: 1px solid var(--border);
  }
}

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.on {
  background: #00ba7c;
}

.dot.err {
  background: var(--danger);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.panel h2 {
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.list {
  overflow-y: auto;
  flex: 1;
}

.list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.list button:hover {
  background: var(--accent-dim);
}

.list button.active {
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
}

.thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #000;
}

.thread-toolbar {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.thread-toolbar a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
}

.composer {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 200px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.composer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.file-btn {
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
}

.file-btn input {
  display: none;
}

.send-btn {
  margin-left: auto;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.post-status {
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.thread iframe {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 320px;
  background: #fff;
}

.hint {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hint code {
  background: var(--panel);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.feed {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  color: var(--muted);
  background: var(--panel);
}

.feed .evt {
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}

.feed .evt strong {
  color: var(--accent);
  font-weight: 600;
}

.empty {
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
