:root {
  --bg: #f6faf8;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --accent: #22c55e;
  --accent-2: #14b8a6;
  --accent-soft: rgba(34, 197, 94, 0.15);
  --accent-ink: #166534;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

/* Ensure HTML `hidden` always wins even if class styles set display. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(to right, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.35;
  pointer-events: none;
}

.shell {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}
.site-logo {
  height: 36px;
  width: auto;
  border-radius: 0;
  object-fit: contain;
  border: 0;
  box-shadow: none;
  background: transparent;
}
.brand-text {
  line-height: 1.1;
}
.brand-name {
  font-weight: 800;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.tab {
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}
.tab.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(34, 197, 94, 0.25);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}
.lang-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}
.lang-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
}
.lang-btn.is-active {
  color: var(--text);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}
.search input {
  border: 0;
  outline: none;
  width: 200px;
  font-size: 13px;
  background: transparent;
  color: var(--text);
}
.search-icon {
  color: var(--muted);
  display: inline-flex;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ghost-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.ghost-btn:hover {
  color: var(--text);
  transform: translateY(-1px);
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover {
  color: var(--text);
  transform: translateY(-1px);
}
.icon-btn.is-on {
  color: var(--text);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}
.avatar-btn {
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.avatar img {
  display: block;
  width: 100%;
  height: 100%;
}
.menu {
  position: absolute;
  right: 18px;
  top: 60px;
  width: 160px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  padding: 6px;
  z-index: 30;
}
.menu-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 10px 10px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}
.menu-item:hover {
  color: var(--text);
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
}

.layout {
  display: grid;
  grid-template-columns: 140px 1fr 330px;
  gap: 16px;
  padding: 16px 24px 28px;
  width: min(1280px, calc(100vw - 48px));
  margin: 0 auto;
}

.nav {
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  position: sticky;
  top: 16px;
  align-self: start;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--line);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--text);
}
.nav-icon {
  width: 20px;
  text-align: center;
}
.nav-text {
  flex: 1;
}

.feed {
  min-width: 0;
}
.feed-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.feed-tabs {
  display: flex;
  gap: 10px;
  align-items: center;
}
.feed-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.feed-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--line);
  color: var(--text);
}
.feed-tab.is-active {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
  color: var(--text);
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.tiny-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  color: var(--muted);
}
.tiny-btn:hover {
  color: var(--text);
}

.thread-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.thread {
  display: grid;
  grid-template-columns: 44px 1fr 140px;
  gap: 10px;
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  transition: background 120ms ease, transform 120ms ease;
}
.thread:last-child {
  border-bottom: 0;
}
.t-avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.28), rgba(59, 130, 246, 0.28));
  border: 1px solid rgba(15, 23, 42, 0.1);
  display: grid;
  place-items: center;
  font-weight: 900;
  color: rgba(15, 23, 42, 0.7);
  user-select: none;
}
.t-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.t-avatar.has-img {
  padding: 0;
  overflow: hidden;
}
.t-avatar.has-img span {
  display: none;
}
.thread:hover {
  background: rgba(255, 255, 255, 0.92);
  transform: translateY(-1px);
}
.t-main {
  min-width: 0;
}
.t-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  margin: 0 0 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.t-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  gap: 6px;
}
.tag svg {
  width: 14px;
  height: 14px;
}
.t-right {
  display: grid;
  justify-items: end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.cate-badge {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
}
.metrics {
  display: flex;
  align-items: center;
  gap: 10px;
}
.metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.metric svg {
  opacity: 0.75;
}
.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.28);
  display: inline-block;
  margin-left: 6px;
}

/* Topic page (in-feed route, NodeSeek-like navigation) */
#topicView {
  display: grid;
  gap: 12px;
}
.topic-page {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.topic-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}
.topic-head-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.topic-head-main {
  min-width: 0;
}
.topic-title {
  font-weight: 900;
  font-size: 16px;
  line-height: 1.25;
  margin-bottom: 6px;
  word-break: break-word;
}
.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.topic-content {
  padding: 12px;
}
.topic-replies {
  padding: 12px;
  display: grid;
  gap: 10px;
}
.topic-replybox {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 16px;
  align-self: start;
}
.card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}
.card-title {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 10px;
}

.profile-card {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.12), rgba(255, 255, 255, 0.85));
}
.profile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.profile-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
  flex: 0 0 auto;
}
.profile-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-name {
  font-weight: 900;
}
.profile-hint {
  font-size: 12px;
  color: var(--muted);
}
.badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.12);
  color: var(--text);
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 12px 0;
}
.stat {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  padding: 10px;
}
.stat-k {
  font-size: 11px;
  color: var(--muted);
}
.stat-v {
  font-weight: 900;
  margin-top: 4px;
}

.primary-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(34, 197, 94, 0.22);
}
.primary-btn:hover {
  filter: brightness(1.02);
  transform: translateY(-1px);
}
.hint-row {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.links {
  display: grid;
  gap: 8px;
}
.links a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.links a:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mini,
.mini-skel {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.35), rgba(59, 130, 246, 0.35));
}
.mini {
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
}
.mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mini-skel {
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.06), rgba(15, 23, 42, 0.02), rgba(15, 23, 42, 0.06));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
/* old decorative gradients removed; avatars are images now */

@keyframes shimmer {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: -200% 0%;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    width: calc(100vw - 24px);
    padding: 12px 12px 18px;
  }
  .tabs {
    display: none;
  }
  .search input {
    width: 140px;
  }
  .nav {
    position: relative;
  }
  .side {
    position: relative;
  }
  .thread {
    grid-template-columns: 44px 1fr;
  }
  .t-right {
    display: none;
  }
}

/* Keep centered on wide screens (NodeSeek-like centered container). */

.toast-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  pointer-events: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
  color: var(--text);
  font-size: 13px;
}
.toast b {
  color: var(--accent-ink);
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.modal {
  position: relative;
  width: min(860px, calc(100vw - 28px));
  max-height: min(86vh, 860px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}
.modal-title {
  font-weight: 900;
}
.modal-body {
  padding: 12px;
  overflow: auto;
  max-height: calc(86vh - 64px);
}

.form {
  display: grid;
  gap: 10px;
}
.field {
  display: grid;
  gap: 6px;
}
.label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}
.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}
.textarea {
  min-height: 140px;
  resize: vertical;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}
.btn:hover {
  color: var(--text);
}
.btn.is-on {
  color: var(--text);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.12);
}
.btn.btn-mini {
  height: 30px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn.primary {
  border-color: rgba(34, 197, 94, 0.3);
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: white;
  box-shadow: 0 10px 22px rgba(34, 197, 94, 0.18);
}
.btn.primary:hover {
  filter: brightness(1.02);
}
.hr {
  height: 1px;
  background: var(--line);
  margin: 8px 0;
}
.topic-body {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
}
.topic-body.md {
  white-space: normal;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}
.tool-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}
.tool-btn:hover {
  color: var(--text);
}

/* Minimal safe markdown styling */
.md-p {
  margin: 0 0 10px 0;
}
.md-pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.04);
  overflow: auto;
}
.md-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}
.md-inline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.04);
}
.md-img {
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}
.md-link {
  color: #0ea5e9;
  text-decoration: none;
  border-bottom: 1px solid rgba(14, 165, 233, 0.25);
}
.md-link:hover {
  border-bottom-color: rgba(14, 165, 233, 0.6);
}
.md-mention {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: var(--accent-ink);
  font-weight: 900;
}
.reply {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.85);
}
.reply-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.icon-dot {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--danger);
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.28);
}
