*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #000;
  color: #e7e9ea;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333639; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Container ─────────────────────────────────────── */

.container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  border-left: 1px solid #2f3336;
  border-right: 1px solid #2f3336;
}

@media (max-width: 600px) {
  .container { border-left: none; border-right: none; }
}

/* ── Header ────────────────────────────────────────── */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 16px;
  height: 53px;
  border-bottom: 1px solid #2f3336;
  display: flex;
  align-items: center;
  gap: 24px;
}

.back-arrow {
  color: #e7e9ea;
  text-decoration: none;
  font-size: 20px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}

.back-arrow:hover { background: rgba(255, 255, 255, 0.1); }

.header h1 { font-size: 20px; font-weight: 700; }

/* ── Nav ───────────────────────────────────────────── */

.nav {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid #2f3336;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.nav::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  color: #71767b;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
  border: 1px solid #2f3336;
}

.nav-link:hover {
  color: #e7e9ea;
  border-color: #555;
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  background: #1d9bf0;
  color: #fff;
  border-color: #1d9bf0;
}

/* ── Case description ──────────────────────────────── */

.case-desc {
  padding: 12px 16px;
  font-size: 14px;
  color: #71767b;
  border-bottom: 1px solid #2f3336;
  background: rgba(255, 255, 255, 0.02);
  line-height: 1.6;
}

/* ── Post card ─────────────────────────────────────── */

.post {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid #2f3336;
  position: relative;
  transition: background 0.15s;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}

.post:hover { background: rgba(255, 255, 255, 0.03); }

/* Current (opened) post */
.post.current {
  box-shadow: inset 3px 0 0 #1d9bf0;
  background: rgba(29, 155, 240, 0.06);
}

.post.current:hover { background: rgba(29, 155, 240, 0.09); }

/* Ancestor posts */
.post.ancestor .post-body { opacity: 0.6; }
.post.ancestor .avatar { opacity: 0.7; }

.post.no-border { border-bottom: none; }

/* ── Thread lines ──────────────────────────────────── */

.post.line-below::after {
  content: '';
  position: absolute;
  left: 35px;
  top: 54px;
  bottom: 0;
  width: 2px;
  background: #333639;
}

.post.line-above::before {
  content: '';
  position: absolute;
  left: 35px;
  top: 0;
  height: 12px;
  width: 2px;
  background: #333639;
}

/* ── Avatar ────────────────────────────────────────── */

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-right: 12px;
}

/* ── Post body ─────────────────────────────────────── */

.post-body { flex: 1; min-width: 0; }

.post-header {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.post-name { font-weight: 700; color: #e7e9ea; }
.post-time { color: #71767b; font-size: 14px; }
.post-text { margin-top: 2px; color: #e7e9ea; }

.post-actions {
  display: flex;
  gap: 24px;
  margin-top: 8px;
  color: #71767b;
  font-size: 13px;
}

.action { cursor: default; transition: color 0.15s; }

/* ── Thread gap ────────────────────────────────────── */

.thread-gap {
  height: 8px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid #2f3336;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}

/* ── Show more ─────────────────────────────────────── */

.show-more {
  padding: 12px 16px;
  color: #1d9bf0;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px solid #2f3336;
  transition: background 0.15s;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}

.show-more:hover { background: rgba(29, 155, 240, 0.06); }

/* ── Hidden thread ─────────────────────────────────── */

.hidden-thread { display: none; }
.hidden-thread.revealed { display: block; }

/* ── Empty state ───────────────────────────────────── */

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: #71767b;
  font-size: 15px;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}

/* ── Compose ───────────────────────────────────────── */

.compose {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #2f3336;
  gap: 12px;
  animation: fadeInUp 0.35s ease both;
  animation-delay: calc(var(--i, 0) * 0.06s);
}

.compose-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #333639;
  flex-shrink: 0;
}

.compose-placeholder { color: #71767b; font-size: 15px; }

/* ── Index page ────────────────────────────────────── */

.tree-view {
  padding: 20px 16px;
  border-bottom: 1px solid #2f3336;
}

.tree-view pre {
  font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.tree-view a { text-decoration: none; }
.tree-view a:hover span { text-decoration: underline; }

.case-list {
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.case-link {
  display: block;
  padding: 14px 16px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid #2f3336;
}

.case-link:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: #555;
}

.case-link-title {
  color: #e7e9ea;
  font-size: 14px;
  line-height: 1.5;
}

.case-link-title strong {
  color: #1d9bf0;
}

/* ── Animations ────────────────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
