:root {
  --ink: #101217;
  --muted: #69707c;
  --line: #e6eaf0;
  --paper: #ffffff;
  --soft: #f5f7fb;
  --brand: #007aff;
  --brand-strong: #0067d8;
  --mint: #1f9d7a;
  --rose: #c14f68;
  --shadow: 0 18px 44px rgba(28, 35, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; }
body {
  color: var(--ink);
  background:
    linear-gradient(180deg, #ffffff 0, #f7f9fc 260px, #fbfcfe 100%);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }

.community-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}
.brand img { width: clamp(112px, 9vw, 146px); }
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}
.top-actions a,
.top-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  border: 0;
  text-decoration: none;
  background: transparent;
}
.top-actions a {
  display: inline-flex;
  align-items: center;
}
.top-actions .active,
.top-actions a:hover {
  color: var(--brand);
  background: #eef6ff;
}
.top-actions .primary-button {
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
}
.top-actions .primary-button:hover {
  color: #fff;
  background: var(--brand-strong);
}
.notification-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.notification-button strong {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
  color: #fff;
  background: #d92d20;
  font-size: 0.72rem;
  line-height: 1;
}
.notification-panel {
  position: fixed;
  top: 86px;
  right: clamp(16px, 4vw, 64px);
  z-index: 45;
  width: min(430px, calc(100% - 32px));
  max-height: min(620px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.notification-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.notification-panel-head h3 {
  margin: 0;
}
.notification-list {
  max-height: 500px;
  overflow: auto;
  display: grid;
}
.notification-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px;
  padding: 13px 16px;
  border-bottom: 1px solid #edf1f6;
  color: inherit;
  text-decoration: none;
}
.notification-item:hover {
  background: #f8fbff;
}
.notification-item.unread {
  background: #eef6ff;
}
.notification-item strong,
.notification-item small,
.notification-item em {
  display: block;
}
.notification-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}
.notification-item em {
  margin-top: 5px;
  color: #4c5564;
  font-style: normal;
  line-height: 1.4;
}
.notification-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #172033;
  font-size: 0.95rem;
  font-weight: 900;
  overflow: hidden;
}
.notification-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.notification-empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}
.primary-button,
.quiet-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.primary-button {
  color: #fff;
  background: var(--brand);
}
.primary-button:hover { background: var(--brand-strong); }
.quiet-button {
  color: #172033;
  background: #fff;
  border-color: var(--line);
}
.icon-button {
  width: 42px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
}

.community-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 34px auto 70px;
}
.loading-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
}
.loader {
  width: 28px;
  height: 28px;
  border: 3px solid #d9e8ff;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.community-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: end;
  padding: clamp(28px, 5vw, 58px) 0 24px;
}
.community-home-hero {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  padding-top: 18px;
}
.community-home-hero > * {
  height: 100%;
  min-height: 310px;
}
.hero-copy-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(22px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 122, 255, 0.08), rgba(31, 157, 122, 0.08)),
    #fff;
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(2.25rem, 5.7vw, 4.8rem);
  line-height: 1.04;
  letter-spacing: 0;
}
.community-home-hero h1 {
  max-width: none;
  font-size: clamp(2rem, 3vw, 3.05rem);
  line-height: 1.08;
}
h2 { font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: 0; }
.hero-copy { color: #3c4451; font-size: 1rem; line-height: 1.5; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.community-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.community-stats span {
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
}
.community-stats strong {
  display: inline;
  color: var(--ink);
  font-size: 1rem;
  margin-right: 4px;
}
.search-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(22px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.search-panel input,
.search-panel select,
.form-grid input,
.form-grid textarea,
.form-grid select,
.comment-form textarea,
.post-form textarea,
.post-form input,
.dialog textarea,
.dialog select {
  width: 100%;
  border: 1px solid #d9dee8;
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
}
.search-panel label,
.form-grid label,
.post-form label,
.dialog label {
  display: grid;
  gap: 7px;
  color: #343b46;
  font-size: 0.9rem;
  font-weight: 800;
}
.search-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
}
.featured-community {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #e4ecf6;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  background: #f8fbff;
}
.featured-community strong,
.featured-community small {
  display: block;
}
.featured-community small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
}
.community-home-layout {
  align-items: start;
}
.feed-column {
  min-width: 0;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin-bottom: 0;
}
.feed-stack { display: grid; gap: 14px; }
.post-card,
.community-card,
.side-panel,
.form-card,
.profile-card,
.comment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(28, 35, 48, 0.05);
}
.post-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  overflow: hidden;
}
.vote-rail {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: linear-gradient(180deg, #f8fbff, #f2f6fb);
}
.vote-rail button {
  width: 34px;
  height: 34px;
  border: 1px solid #dfe6ef;
  border-radius: 8px;
  background: #fff;
  color: #394151;
  font-weight: 900;
}
.score { font-weight: 900; }
.post-body { min-width: 0; padding: 16px 18px; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
}
.meta a { color: var(--brand); text-decoration: none; font-weight: 800; }
.post-body h2,
.post-body h3 { margin: 8px 0 8px; }
.post-body h2 {
  font-size: clamp(1.25rem, 2vw, 1.95rem);
  line-height: 1.15;
}
.post-body h2 a,
.post-body h3 a { text-decoration: none; }
.post-excerpt {
  color: #4c5564;
  line-height: 1.62;
  white-space: pre-wrap;
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.text-button {
  border: 0;
  padding: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 850;
}
.danger { color: var(--rose); }
.sidebar { display: grid; gap: 14px; align-content: start; }
.side-panel { padding: 16px; }
.side-panel h3 { margin-bottom: 10px; }
.side-panel p { color: #4c5564; line-height: 1.45; }
.community-list { display: grid; gap: 10px; }
.community-mini {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-decoration: none;
  padding: 8px;
  border-radius: 8px;
}
.community-mini:hover {
  background: #f3f8ff;
}
.community-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #007aff, #1f9d7a);
  font-weight: 900;
  overflow: hidden;
}
.community-icon img { width: 100%; height: 100%; object-fit: cover; }
.community-mini strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-mini small { color: var(--muted); }
.community-founder {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.community-founder > span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}
.community-founder a {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  text-decoration: none;
}
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
.directory-section {
  margin-top: 28px;
}
.community-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.community-card:hover {
  transform: translateY(-2px);
  border-color: #cfe5ff;
  box-shadow: var(--shadow);
}
.community-card h3 { margin-bottom: 0; }
.community-card h3 a { text-decoration: none; }
.community-card p { color: #4d5665; line-height: 1.6; }
.community-banner {
  min-height: 210px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #eef6ff, #eefaf6);
  display: flex;
  align-items: end;
  padding: 20px;
  overflow: hidden;
}
.community-banner.has-image {
  background-size: cover;
  background-position: center;
}
.community-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0;
}
.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
}
.tabs button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 13px;
  background: #fff;
  font-weight: 850;
}
.tabs button.active {
  color: var(--brand);
  background: #eef6ff;
  border-color: #cfe5ff;
}
.muted { color: var(--muted); }
.form-card { padding: clamp(18px, 4vw, 30px); }
.moderation-panel {
  border-color: #cfe5ff;
  background: #f8fbff;
}
.danger-zone {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #dbe7f4;
}
.danger-zone p {
  margin: 0;
}
.danger-zone span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}
.danger-button {
  color: #a32336;
  border-color: #f0c8d0;
  background: #fff7f8;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.span-two { grid-column: 1 / -1; }
.post-form { display: grid; gap: 12px; margin-bottom: 16px; }
.comment-list { display: grid; gap: 12px; }
.comment-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.comment-card.reply {
  margin-left: 28px;
  border-left: 3px solid #dbeafe;
}
.comment-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.comment-head-copy {
  min-width: 0;
}
.comment-avatar {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #172033;
  font-size: 0.95rem;
  font-weight: 900;
  overflow: hidden;
}
.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.comment-score {
  padding: 2px 7px;
  border-radius: 999px;
  color: #526070;
  background: #f2f5f9;
  font-weight: 850;
}
.comment-score.has-own-vote {
  color: #075fb8;
  background: #e9f4ff;
}
.comment-vote-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 48px;
}
.comment-vote-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #d9e2ee;
  border-radius: 999px;
  padding: 0 11px;
  color: #394151;
  background: #fff;
  font-weight: 900;
}
.comment-vote-button span {
  min-width: 12px;
  color: #647084;
  font-weight: 850;
}
.comment-vote-button.up.active {
  color: #0067d8;
  border-color: #b8dcff;
  background: #e9f4ff;
}
.comment-vote-button.down.active {
  color: #b42338;
  border-color: #f0c8d0;
  background: #fff3f5;
}
.comment-vote-button:hover {
  border-color: #b8dcff;
  transform: translateY(-1px);
}
.comment-form { display: grid; gap: 10px; margin: 16px 0; }
.root-comment-form textarea {
  min-height: 86px;
}
.root-comment-form .primary-button,
.comment-reply-form .primary-button {
  min-width: 150px;
}
.comment-reply-form {
  display: grid;
  gap: 10px;
  margin-left: 48px;
  padding: 12px;
  border: 1px solid #dbe7f4;
  border-radius: 8px;
  background: #f8fbff;
}
.comment-reply-form[hidden] {
  display: none;
}
.comment-reply-form label {
  display: grid;
  gap: 7px;
  color: #343b46;
  font-size: 0.9rem;
  font-weight: 800;
}
.comment-reply-form textarea {
  width: 100%;
  border: 1px solid #d9dee8;
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
}
.login-required-card h3 {
  margin-bottom: 6px;
}
.login-required-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}
.login-required-card .primary-button {
  width: fit-content;
}
.empty {
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 16px;
  border-radius: 8px;
  color: #fff;
  background: #172033;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b42338; }
.dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}
.dialog form { display: grid; gap: 14px; padding: 18px; }
.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.profile-card { padding: 18px; }
.profile-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #172033;
  font-size: 1.4rem;
  font-weight: 900;
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-stats {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.profile-stats span {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}
.profile-stats strong { display: block; font-size: 1.4rem; }

@media (max-width: 820px) {
  .community-topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; overflow-x: auto; }
  .notification-panel {
    top: 132px;
    right: 16px;
  }
  .community-hero,
  .layout { grid-template-columns: 1fr; }
  .hero-copy-block { min-height: auto; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .sidebar { order: -1; }
  .search-row,
  .form-grid { grid-template-columns: 1fr; }
  .post-card { grid-template-columns: 48px minmax(0, 1fr); }
  .vote-rail { padding-inline: 6px; }
  .comment-card.reply { margin-left: 12px; }
  .comment-vote-row { margin-left: 0; }
  .comment-reply-form { margin-left: 0; }
}
