:root {
  --primary: #05c3dd;
  --primary-dark: #0499ad;
  --primary-soft: rgba(5, 195, 221, 0.14);
  --bg: #f4fafb;
  --surface: #fff;
  --ink: #0a1f24;
  --muted: #5a7a82;
  --line: #dceef1;
  --soft: #eaf8fa;
  --danger: #f6465d;
  --success: #00c076;
  --gold: #c8923e;
  --celebrity: #f6c453;
  --radius: 18px;
  --shadow: 0 16px 48px rgba(5, 80, 92, 0.12);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.community-app { min-height: 100vh; }
.community-topbar {
  position: sticky; top: 0; z-index: 40; height: 56px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 2px 8px rgba(0,0,0,.04);
}
.community-topbar-inner {
  width: 100%; max-width: none; height: 100%; margin: 0; padding: 0 16px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.community-brand { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: url("../icons/icon.svg") center / 28px 28px no-repeat, var(--primary);
  flex-shrink: 0;
}
.brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.top-search {
  position: relative; flex: 1; min-width: 0; max-width: 320px;
  display: flex; align-items: center;
}
.top-search-icon {
  position: absolute; left: 12px; width: 16px; height: 16px; color: #65676b; pointer-events: none;
}
.top-search input {
  width: 100%; height: 40px; padding: 0 12px 0 36px; border: 0; border-radius: 20px;
  background: #f0f2f5; color: var(--ink); outline: none;
}
.top-search input::placeholder { color: #65676b; }
.top-search-results {
  position: absolute; left: 0; right: auto; top: calc(100% + 8px); z-index: 50;
  width: min(360px, 80vw); max-height: 420px; overflow: auto;
  padding: 8px; border-radius: 12px; background: #fff;
  box-shadow: 0 12px 28px rgba(0,0,0,.15);
}
.search-label { padding: 8px 10px 4px; font-size: 13px; font-weight: 800; color: var(--ink); }
.search-empty { padding: 16px; color: var(--muted); font-size: 13px; }
.search-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: inherit;
}
.search-row:hover { background: #f0f2f5; }
.search-row span { min-width: 0; display: grid; }
.search-row em { font-style: normal; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-avatar, .search-avatar.avatar-fallback {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--soft); font-size: 14px;
}
.desktop-nav {
  display: flex; align-items: stretch; height: 56px; justify-self: center;
}
.desktop-nav a {
  width: 112px; height: 100%; display: grid; place-items: center;
  color: #65676b; border-bottom: 3px solid transparent; border-radius: 0;
  padding: 0; font-size: 0;
}
.desktop-nav a svg { width: 26px; height: 26px; }
.desktop-nav a:hover { background: #f0f2f5; border-radius: 8px; height: 48px; align-self: center; }
.desktop-nav a.is-active {
  color: var(--primary); border-bottom-color: var(--primary); background: transparent;
}
.desktop-nav a.is-active:hover { height: 100%; border-radius: 0; background: transparent; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.circle-button, .icon-button, .avatar-button, .language-button {
  border: 0; background: #e4e6eb; color: #050505; cursor: pointer; display: grid; place-items: center;
}
.circle-button, .icon-button { width: 40px; height: 40px; border-radius: 50%; }
.circle-button svg, .icon-button svg { width: 20px; height: 20px; }
.circle-button:hover, .icon-button:hover { background: #d8dadf; }
.avatar-button { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; font-weight: 800; }
.avatar-button img { width: 100%; height: 100%; object-fit: cover; }
.language-button { height: 36px; min-width: 56px; padding: 0 10px; border-radius: 10px; font-size: 12px; font-weight: 800; }
.nav-badge {
  position: absolute; top: -4px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 9px; color: #fff; background: #e41e3f; font-size: 10px; font-weight: 800;
}
.tab-icon-wrap { position: relative; display: inline-grid; place-items: center; }
.community-main {
  width: 100%; max-width: none;
  min-height: calc(100vh - 56px); margin: 0;
  padding: 16px 20px 72px;
}
.mobile-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: 64px;
  display: none; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,.96);
}
.mobile-tabs a { display: grid; place-items: center; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.mobile-tabs a svg { width: 22px; height: 22px; }
.mobile-tabs a.is-active { color: var(--primary-dark); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.03em; }
.muted { color: var(--muted); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); cursor: pointer; font-weight: 700;
}
.button.primary { border-color: transparent; background: linear-gradient(135deg, #17e0e0, var(--primary)); color: #04252b; }
.button.full { width: 100%; }
.button.sm { padding: 10px 14px; font-size: 13px; min-height: auto; }
.button.danger { color: var(--danger); border-color: rgba(246,70,93,.25); }
.auth-code-row { display: flex; gap: 8px; align-items: stretch; }
.auth-code-row input { flex: 1; min-width: 0; }
.auth-code-row .button { flex-shrink: 0; align-self: stretch; }
.auth-switch-line { margin: 14px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.auth-switch {
  border: 0; background: none; padding: 0; margin: 0;
  color: var(--primary-dark); font-weight: 700; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.auth-switch:hover { color: var(--primary); }
#authStatus { margin-top: 10px; min-height: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.field textarea { min-height: 96px; resize: vertical; }

.feed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
  width: 100%;
}
.feed-aside { align-self: start; position: sticky; top: 72px; width: 100%; }
.composer, .post-card, .panel-card, .thread-card, .group-card, .profile-card {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.composer, .post-card, .panel-card { padding: 16px; margin-bottom: 14px; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.composer-actions-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.guest-composer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.guest-composer-text { margin: 0; flex: 1; min-width: 200px; }
.comment-guest-hint { margin: 10px 0 0; font-size: 13px; }
.link-button { background: none; border: none; padding: 0; color: var(--primary-dark); font: inherit; cursor: pointer; text-decoration: underline; }

.cm-select { position: relative; min-width: 148px; }
.cm-select-trigger {
  width: 100%; justify-content: space-between; padding-right: 12px;
  background: #fff; color: var(--ink);
}
.cm-select-label { flex: 1; text-align: left; }
.cm-select-chevron {
  width: 16px; height: 16px; margin-left: 8px; flex-shrink: 0;
  stroke: var(--muted); transition: transform .16s ease;
}
.cm-select.is-open .cm-select-chevron { transform: rotate(180deg); }
.cm-select-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  padding: 6px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; box-shadow: var(--shadow);
}
.cm-select-option {
  width: 100%; display: flex; align-items: center; min-height: 40px;
  padding: 0 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--ink); font-weight: 600; text-align: left; cursor: pointer;
}
.cm-select-option:hover { background: var(--soft); }
.cm-select-option.is-active {
  color: var(--primary-dark); background: var(--primary-soft); font-weight: 800;
}

/* 隐藏仍存在的原生 select，统一走自定义组件 */
.field select,
.composer select {
  appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a7a82' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  padding-right: 38px;
}
.post-head { display: flex; gap: 12px; align-items: flex-start; }
.post-head .avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--soft); }
.avatar-fallback {
  display: inline-grid; place-items: center; flex-shrink: 0;
  color: var(--primary-dark); background: var(--primary-soft); font-weight: 800;
}
.post-head .avatar-fallback { width: 44px; height: 44px; border-radius: 50%; font-size: 16px; }
.profile-link { display: inline-flex; flex-shrink: 0; color: inherit; }
.post-user-name { color: inherit; font: inherit; }
.post-user-name:hover { text-decoration: underline; }
.post-meta { flex: 1; min-width: 0; }
.post-meta strong, .thread-title strong, .profile-name strong { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.follow-sep { color: var(--muted); font-weight: 700; margin: 0 2px; }
.follow-text {
  border: 0; padding: 0; background: none; cursor: pointer;
  color: var(--primary-dark); font-size: 13px; font-weight: 800;
}
.follow-text:hover { text-decoration: underline; }
.follow-text.is-on { color: var(--muted); font-weight: 700; }
.post-body { margin: 12px 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-images { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.post-images img { width: 100%; border-radius: 12px; object-fit: cover; aspect-ratio: 1; cursor: pointer; }
.post-actions {
  display: flex; margin-top: 8px; padding-top: 4px;
  border-top: 1px solid var(--line);
}
.post-action {
  flex: 1; min-width: 0; min-height: 40px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 6px; background: transparent;
  color: #65676b; font-size: 15px; font-weight: 600; cursor: pointer;
}
.post-action svg { width: 20px; height: 20px; flex-shrink: 0; }
.post-action:hover { background: #f2f3f5; }
.post-action.is-on { color: var(--primary-dark); }
.comment-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.comment-item { display: flex; gap: 10px; margin-top: 10px; }
.comment-item img, .comment-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--soft);
}
.comment-item .avatar-fallback { width: 32px; height: 32px; font-size: 12px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input { flex: 1; }

.display-name.is-member {
  background: linear-gradient(90deg, #1a1208 0%, #c8923e 35%, #ffe7a8 55%, #1a1208 100%);
  background-size: 220% auto; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: member-shine 4s linear infinite;
}
@keyframes member-shine { to { background-position: 220% center; } }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 800; line-height: 1.2; vertical-align: middle;
}
.badge.member { color: #1a1208; background: linear-gradient(135deg, #ffe7a8, #c8923e); }
.badge.verified { color: #fff; background: var(--primary-dark); }
.badge.celebrity { color: #1a1208; background: var(--celebrity); }
.badge.official { color: #fff; background: #04252b; }
.badge.group-official { color: #04252b; background: var(--primary); }

.messages-layout, .groups-layout {
  display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px;
  min-height: calc(100vh - 88px); width: 100%;
}
.list-panel, .chat-panel { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.list-panel { display: flex; flex-direction: column; }
.list-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; }
.list-scroll { overflow: auto; max-height: 560px; }
.thread-card, .group-card { width: 100%; display: flex; gap: 12px; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.thread-card:hover, .group-card:hover, .thread-card.is-active, .group-card.is-active { background: var(--soft); }
.thread-card img, .group-card img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; }
.chat-panel { display: flex; flex-direction: column; }
.chat-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; }
.chat-messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 360px; }
.chat-bubble { max-width: 78%; padding: 10px 12px; border-radius: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-bubble.mine { align-self: flex-end; background: var(--primary-soft); border: 1px solid rgba(5,195,221,.25); }
.chat-bubble.theirs { align-self: flex-start; background: #f7fbfc; border: 1px solid var(--line); }
.chat-bubble img, .chat-bubble video { max-width: 240px; border-radius: 10px; display: block; margin-top: 6px; }
.chat-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-compose input { flex: 1; }
.chat-compose label.button { position: relative; overflow: hidden; }
.chat-compose input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.profile-hero { position: relative; overflow: hidden; border-radius: var(--radius); margin-bottom: 16px; }
.profile-cover { height: 180px; background: linear-gradient(135deg, #04252b, var(--primary)); }
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-card { margin-top: -54px; position: relative; padding: 16px; }
.profile-top { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.profile-avatar, .profile-avatar.avatar-fallback {
  width: 96px; height: 96px; border-radius: 50%; border: 4px solid #fff; object-fit: cover; background: var(--soft);
}
.profile-avatar.avatar-fallback { font-size: 32px; }
.profile-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.profile-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; }
.profile-stats strong { display: block; font-size: 18px; }
.profile-stats span { color: var(--muted); font-size: 12px; }
.edit-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.edit-avatar-row .profile-avatar { width: 72px; height: 72px; border-width: 2px; }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,37,43,.45); }
.modal-card {
  position: relative; width: min(440px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  padding: 22px; border-radius: 18px; background: #fff; box-shadow: var(--shadow);
}
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); }
.checkin-days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.checkin-day { padding: 10px 6px; border: 1px solid var(--line); border-radius: 11px; text-align: center; background: var(--soft); }
.checkin-day.is-current { border-color: var(--primary); }
.checkin-day.is-checked { background: var(--primary); color: #04252b; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 120;
  padding: 10px 16px; border-radius: 12px; background: rgba(4,37,43,.92); color: #fff; font-size: 13px; font-weight: 700;
}
.empty-state { padding: 48px 16px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .feed-layout, .messages-layout, .groups-layout { grid-template-columns: 1fr; }
  .feed-aside { position: static; }
  .chat-panel { min-height: 420px; }
  .desktop-nav a { width: 72px; }
}
@media (max-width: 760px) {
  .community-topbar-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .desktop-nav { display: none; }
  .brand-text { position: static; width: auto; height: auto; clip: auto; overflow: visible; font-weight: 800; font-size: 16px; }
  .top-search { max-width: none; }
  .mobile-tabs { display: grid; }
  .community-main { padding-bottom: 88px; }
}
