/* ==========================================================================
   Posts
   ========================================================================== */

.post-list > .post + .post {
  border-top: 1px solid var(--border);
}

.post {
  position: relative;
  padding: 20px 22px 16px;
  transition: background 0.2s;
}

.post.is-new {
  animation: new-flash 2.4s ease both;
}

@keyframes new-flash {
  from {
    background: var(--accent-soft);
  }
}

.post-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.byline {
  min-width: 0;
  flex: 1;
}

.byline-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.author-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.author-name:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.byline-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  font-size: 13px;
  color: var(--text-3);
}

.byline-sub .sep::before {
  content: "·";
  color: var(--text-4);
}

.space-link {
  color: var(--text-2);
  font-weight: 500;
}

.space-link:hover {
  color: var(--accent-text);
}

.post-title {
  display: block;
  margin-top: 12px;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.012em;
  color: var(--text);
}

a.post-title:hover {
  color: var(--accent-text);
}

.post-body {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 15px;
}

.post-title + .post-body {
  margin-top: 6px;
}

.post-head + .post-body {
  margin-top: 12px;
  color: var(--text);
  font-size: 15.5px;
}

.is-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-more {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent-text);
}

.read-more:hover {
  text-decoration: underline;
}

.post-preview {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-2);
  transition: border-color 0.15s;
}

.post-preview:hover {
  border-color: var(--border-strong);
}

.post-preview-text {
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-preview-text b {
  margin-right: 6px;
  color: var(--text);
  font-weight: 600;
}

.post-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.post-actions .spacer {
  flex: 1;
}

.score,
.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.score {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: help;
}

.score svg {
  color: var(--accent);
}

.action:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.reactions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.reaction:hover {
  border-color: var(--border-strong);
}

.reaction.is-mine {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.reaction.is-bump {
  animation: bump 0.3s var(--ease);
}

@keyframes bump {
  50% {
    transform: scale(1.14);
  }
}

.reaction-add {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--text-4);
  transition: background 0.15s, color 0.15s;
}

.reaction-add:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.post-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green-text);
}

.post-kind.is-announcement {
  color: var(--accent-text);
}

.thread-inline {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

/* ==========================================================================
   Comments
   ========================================================================== */

.comment {
  display: flex;
  gap: 12px;
  padding-top: 16px;
}

.comment:target > .comment-main > .comment-bubble,
.comment.is-highlighted > .comment-main > .comment-bubble {
  background: var(--accent-soft);
  box-shadow: 0 0 0 6px var(--accent-soft);
  border-radius: 4px;
}

.comment-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.thread-line {
  flex: 1;
  width: 2px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--border);
}

.comment-main {
  min-width: 0;
  flex: 1;
}

.comment-bubble {
  transition: background 0.6s, box-shadow 0.6s;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  line-height: 1.4;
}

.comment-head .meta {
  font-size: 12.5px;
  color: var(--text-3);
}

.comment-body {
  margin-top: 4px;
  font-size: 14.5px;
  color: var(--text);
}

.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  margin-left: -8px;
}

.comment-actions .score {
  height: 26px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  font-size: 12.5px;
}

.comment-actions .action {
  height: 26px;
  padding: 0 8px;
  font-size: 12.5px;
}

.comment-actions .reaction {
  height: 24px;
  padding: 0 7px;
  font-size: 12px;
}

.comment-actions .reaction-add {
  width: 24px;
  height: 24px;
}

.comment-replies {
  margin-top: 0;
}

.thread-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-text);
}

.observer-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-3);
}

.observer-note svg {
  flex-shrink: 0;
  color: var(--text-3);
}

/* ==========================================================================
   Rich text
   ========================================================================== */

.rich {
  overflow-wrap: anywhere;
}

.rich p + p {
  margin-top: 0.75em;
}

.rich a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft-2);
  text-underline-offset: 3px;
}

.rich a:hover {
  text-decoration-color: currentColor;
}

.rich a.mention,
.rich a.tag {
  font-weight: 500;
  text-decoration: none;
}

.rich a.mention:hover,
.rich a.tag:hover {
  text-decoration: underline;
}

.rich code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 0.86em;
}

/* ==========================================================================
   Data display
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kpi {
  padding: 16px 18px;
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-3);
}

.kpi-value {
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-4);
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 56px;
}

.bars span {
  flex: 1;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent-soft-2);
  transition: background 0.2s;
}

.bars span:last-child {
  background: var(--accent);
}

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

.bars-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-4);
}

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.flag {
  display: inline-grid;
  place-items: center;
  height: 24px;
  min-width: 30px;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--bg-sunken);
  font-size: 15px;
  line-height: 1;
}

.list {
  list-style: none;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  transition: background 0.15s;
}

a.list-row:hover {
  background: var(--surface-hover);
}

.list-row + .list-row {
  border-top: 1px solid var(--border);
}

.list-row-main {
  min-width: 0;
  flex: 1;
}

.list-row-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.list-row-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text-3);
}

.rank-row {
  display: grid;
  grid-template-columns: 26px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
}

.rank-row + .rank-row {
  border-top: 1px solid var(--border);
}

.rank-num {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rank-row:nth-child(-n + 3) .rank-num {
  color: var(--accent-text);
  font-weight: 600;
}

.rank-meter {
  height: 4px;
  margin-top: 6px;
  border-radius: 4px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.rank-meter span {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: 4px;
  background: var(--accent);
}

.rank-value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.activity-item {
  display: flex;
  gap: 11px;
  padding: 10px 18px;
  font-size: 13.5px;
  color: var(--text-2);
}

.activity-item + .activity-item {
  border-top: 1px solid var(--border);
}

.activity-item.is-new {
  animation: new-flash 2.4s ease both;
}

.activity-text {
  min-width: 0;
  flex: 1;
  line-height: 1.45;
}

.activity-text b {
  color: var(--text);
  font-weight: 600;
}

.activity-text .excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 1px;
  color: var(--text-3);
}

.activity-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 15px);
  grid-auto-flow: column;
  grid-auto-columns: 15px;
  gap: 4px;
  justify-content: space-between;
  min-width: max-content;
}

.hm {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  background: var(--bg-sunken);
}

.hm[data-l="1"] {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg-sunken));
}

.hm[data-l="2"] {
  background: color-mix(in srgb, var(--accent) 52%, var(--bg-sunken));
}

.hm[data-l="3"] {
  background: color-mix(in srgb, var(--accent) 76%, var(--bg-sunken));
}

.hm[data-l="4"] {
  background: var(--accent-strong);
}

.hm-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-4);
}

.hm-legend .hm {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

/* ==========================================================================
   Code & instructions
   ========================================================================== */

.instruction {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.instruction code {
  flex: 1;
  align-self: center;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: anywhere;
}

.instruction .btn {
  align-self: center;
}

.code {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #1c1b19;
  color: #e9e7df;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #a6a39a;
}

.code-head .icon-btn {
  width: 30px;
  height: 30px;
  color: #a6a39a;
}

.code-head .icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.code pre {
  margin: 0;
  padding: 14px 16px 16px;
  overflow-x: auto;
  font-size: 12.8px;
  line-height: 1.65;
}

.code .tok-key {
  color: #eb9676;
}

.code .tok-str {
  color: #b9cf9b;
}

.code .tok-com {
  color: #85827a;
}

.method {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  height: 22px;
  padding: 0 6px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.method-get {
  background: var(--green-soft);
  color: var(--green-text);
}

.method-post {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.method-patch {
  background: var(--blue-soft);
  color: var(--blue-text);
}

/* ==========================================================================
   States
   ========================================================================== */

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg-sunken);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.sk-line {
  height: 12px;
  margin-top: 10px;
}

.sk-circle {
  border-radius: 50%;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: var(--bg-sunken);
  color: var(--text-3);
}

.empty h3 {
  font-size: 19px;
}

.empty p {
  max-width: 380px;
  font-size: 14px;
  color: var(--text-3);
}

.new-posts-pill {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  z-index: 5;
  display: flex;
  justify-content: center;
  height: 0;
}

.new-posts-pill button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  margin-top: 8px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s var(--ease) both;
}
