:root {
  color-scheme: light;
  --page-overlay: rgba(245, 250, 253, 0.6);
  --surface: rgba(255, 255, 255, 0.45);
  --surface-strong: rgba(255, 255, 255, 0.85);
  --surface-soft: rgba(242, 248, 251, 0.55);
  --text: #253039;
  --muted: #6e7b86;
  --border: rgba(255, 255, 255, 0.7);
  --line: rgba(79, 111, 130, 0.18);
  --primary: #397f9c;
  --primary-hover: #2e6d87;
  --accent: #bd6e91;
  --gold: #b78632;
  --danger: #b84d58;
  --shadow: 0 16px 40px rgba(52, 88, 110, 0.15);
  --hero-image: url("https://img.cdn1.vip/i/6a6233bb85ec1_1784820667.webp");
  --page-image: url("https://img.cdn1.vip/i/6a6232de8684e_1784820446.webp");
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-overlay: rgba(20, 23, 30, 0.65);
  --surface: rgba(34, 38, 47, 0.5);
  --surface-strong: rgba(39, 43, 53, 0.9);
  --surface-soft: rgba(26, 30, 38, 0.55);
  --text: #f3f5f7;
  --muted: #aab3bd;
  --border: rgba(255, 255, 255, 0.13);
  --line: rgba(255, 255, 255, 0.1);
  --primary: #70b9d5;
  --primary-hover: #87c8df;
  --accent: #e08cac;
  --gold: #e5b95e;
  --danger: #ef8490;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  --hero-image: url("https://img.cdn1.vip/i/6a6233ed596c9_1784820717.webp");
  --page-image: url("https://img.cdn1.vip/i/6a623443ddb6d_1784820803.webp");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page-overlay: rgba(20, 23, 30, 0.65);
    --surface: rgba(34, 38, 47, 0.5);
    --surface-strong: rgba(39, 43, 53, 0.9);
    --surface-soft: rgba(26, 30, 38, 0.55);
    --text: #f3f5f7;
    --muted: #aab3bd;
    --border: rgba(255, 255, 255, 0.13);
    --line: rgba(255, 255, 255, 0.1);
    --primary: #70b9d5;
    --primary-hover: #87c8df;
    --accent: #e08cac;
    --gold: #e5b95e;
    --danger: #ef8490;
    --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
    --hero-image: url("https://img.cdn1.vip/i/6a6233ed596c9_1784820717.webp");
    --page-image: url("https://img.cdn1.vip/i/6a623443ddb6d_1784820803.webp");
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  color: var(--text);
  background-color: #e9f2f6;
  background-image: var(--page-image);
  background-position: center top;
  background-size: cover;
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background: var(--page-overlay);
}

button, input, textarea {
  color: inherit;
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

textarea {
  resize: none;
}

.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

/* 启动画面 */
.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--primary);
  font-weight: 700;
}

.boot-mark {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  animation: breathe 1.5s ease-in-out infinite;
}

/* 登录 */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px 26px;
  border-radius: 12px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}

.auth-panel h1 {
  margin: 0;
  text-align: center;
  font-size: 30px;
}

.auth-subtitle {
  text-align: center;
  margin: 8px 0 24px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field > span,
.avatar-fieldset legend {
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field textarea,
.composer textarea,
.reply-form textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  padding: 10px 13px;
}

.field input {
  height: 46px;
}

.field textarea {
  min-height: 100px;
}

.field input:focus,
.field textarea:focus,
.composer textarea:focus,
.reply-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65, 132, 158, 0.15);
}

.primary-button, .small-primary-button {
  color: white;
  background: var(--primary);
  border-radius: 7px;
  font-weight: 700;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
}

.small-primary-button {
  min-height: 36px;
  padding: 0 14px;
}

.primary-button:hover, .small-primary-button:hover {
  background: var(--primary-hover);
}

.login-button {
  width: 100%;
}

.secondary-button, .load-more {
  min-height: 40px;
  padding: 0 14px;
  color: var(--primary);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-weight: 700;
}

.secondary-button:hover, .load-more:hover {
  background: var(--surface-strong);
}

.danger-button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--danger);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-weight: 700;
}

.text-button {
  min-height: 34px;
  padding: 0 9px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}

.form-error {
  min-height: 21px;
  margin: 11px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* 顶部导航 */
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  border-width: 0 0 1px;
}

.topbar-inner {
  width: min(1160px, calc(100% - 32px));
  min-height: 64px;
  margin: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wordmark {
  flex: 0 0 auto;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  background: none;
  padding: 0;
  cursor: pointer;
}

.header-members {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  padding-left: 8px;
}

.header-members .avatar-slot {
  margin-left: -8px;
  border: 2px solid var(--surface-strong);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 50%;
  font-size: 20px;
}

.icon-button:hover, .account-button:hover {
  background: var(--surface-soft);
}

.account-button {
  max-width: 170px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 9px 4px 5px;
  color: var(--text);
  background: transparent;
  border-radius: 7px;
  font-weight: 700;
}

.account-button > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-slot {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: white;
  background: var(--primary);
  border-radius: 50%;
  font-weight: 800;
}

.avatar-slot img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-slot > span {
  position: absolute;
}

.small-avatar {
  width: 34px;
  height: 34px;
}

/* 英雄区域 */
.page {
  width: min(1160px, calc(100% - 32px));
  margin: 22px auto 70px;
}

.hero {
  min-height: 230px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background-image: var(--hero-image);
  background-position: center 43%;
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero::before {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(22, 35, 48, 0.4);
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  padding: 30px;
  color: white;
}

.hero-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
}

.hero h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.15;
}

.hero-content > p:not(.hero-label) {
  margin: 8px 0 14px;
}

.hero-status {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 700;
}

.content-layout {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  align-items: start;
  gap: 22px;
}

.main-column {
  min-width: 0;
}

.side-column {
  position: sticky;
  top: 86px;
  display: grid;
  gap: 16px;
}

/* 公告 */
.announcement {
  display: flex;
  gap: 13px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border-radius: 8px;
}

.announcement-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 50%;
}

.announcement-content {
  min-width: 0;
}

.announcement-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.announcement-heading time {
  color: var(--muted);
  font-size: 12px;
}

.announcement-content p {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* 发布框 */
.composer {
  padding: 20px;
  border-radius: 8px;
}

.composer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-heading h2 {
  margin: 0;
  font-size: 18px;
}

.composer-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.composer-avatar {
  width: 42px;
  height: 42px;
}

.composer textarea {
  min-height: 120px;
  max-height: 240px;
  margin-top: 15px;
  line-height: 1.7;
}

.composer-footer {
  min-height: 44px;
  margin-top: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.character-count {
  color: var(--muted);
  font-size: 13px;
}

.character-count.over-limit {
  color: var(--danger);
  font-weight: 700;
}

/* 留言流 */
.feed {
  margin-top: 28px;
}

.feed-header {
  min-height: 44px;
  margin-bottom: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feed-header h2 {
  margin: 0;
  font-size: 18px;
}

.feed-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.messages {
  display: grid;
  gap: 13px;
}

.message {
  padding: 18px;
  border-radius: 8px;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.message-avatar {
  width: 42px;
  height: 42px;
}

.message-meta {
  min-width: 0;
  flex: 1;
  display: grid;
}

.message-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-time, .reply-time {
  color: var(--muted);
  font-size: 12px;
}

.message-delete, .reply-delete, .dialog-close {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 50%;
}

.message-delete {
  width: 34px;
  height: 34px;
  font-size: 21px;
}

.message-delete:hover, .reply-delete:hover {
  color: var(--danger);
  background: rgba(184, 77, 88, 0.15);
}

.message-content {
  margin: 14px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.75;
}

.message-actions {
  min-height: 38px;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.action-button {
  min-width: 58px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}

.action-button:hover {
  background: var(--surface-soft);
}

.like-button.liked {
  color: var(--accent);
  font-weight: 800;
}

.like-icon {
  font-size: 20px;
  line-height: 1;
}

.reply-zone {
  margin-top: 5px;
}

.reply-list {
  display: grid;
  gap: 8px;
}

.reply {
  position: relative;
  display: flex;
  gap: 9px;
  padding: 10px 11px;
  background: var(--surface-soft);
  border-left: 3px solid rgba(75, 139, 163, 0.45);
  border-radius: 0 7px 7px 0;
}

.reply-avatar {
  width: 31px;
  height: 31px;
}

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

.reply-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.reply-author {
  font-size: 14px;
}

.reply-content {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.65;
}

.reply-delete {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.reply-expand {
  min-height: 34px;
  margin-top: 4px;
  padding: 0 8px;
  color: var(--primary);
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.reply-form {
  margin-top: 9px;
  padding: 11px;
  background: var(--surface-soft);
  border-radius: 7px;
}

.reply-form textarea {
  min-height: 76px;
  padding: 10px;
}

.reply-form-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.feed-status, .empty-state {
  padding: 32px 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: grid;
  gap: 4px;
  border-radius: 8px;
}

.load-more {
  width: 100%;
  margin-top: 13px;
}

/* 侧栏 */
.profile-panel, .members-panel {
  overflow: hidden;
  border-radius: 8px;
}

.profile-panel {
  padding: 0 18px 18px;
  text-align: center;
}

.profile-cover {
  height: 82px;
  margin: 0 -18px;
  background-image: var(--hero-image);
  background-position: center;
  background-size: cover;
}

.profile-avatar {
  width: 76px;
  height: 76px;
  margin: -38px auto 9px;
  border: 4px solid var(--surface-strong);
}

.profile-panel p {
  min-height: 42px;
  margin: 5px 0 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 14px;
}

.members-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.member-list {
  margin-top: 12px;
  display: grid;
  gap: 5px;
}

.member-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border-radius: 7px;
}

.member-row:hover {
  background: var(--surface-soft);
}

.member-avatar {
  width: 35px;
  height: 35px;
}

.member-info {
  min-width: 0;
  display: grid;
}

.member-info strong, .member-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-info strong {
  font-size: 14px;
}

.member-info span {
  color: var(--muted);
  font-size: 11px;
}

/* 对话框 */
.dialog {
  width: min(520px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  overflow: visible;
  color: var(--text);
  background: transparent;
  border: 0;
}

.dialog::backdrop {
  background: rgba(14, 22, 29, 0.55);
  backdrop-filter: blur(7px);
}

.dialog-panel {
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 8px;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  font-size: 24px;
}

.avatar-fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.avatar-fieldset legend {
  margin-bottom: 8px;
}

.avatar-choices {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 1fr));
  gap: 8px;
}

.avatar-choice {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
}

.avatar-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.avatar-choice .avatar-slot {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.avatar-choice:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(65, 132, 158, 0.17);
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.admin-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.migration-block {
  display: grid;
  gap: 12px;
}

.migration-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 15px;
  color: white;
  background: #26313a;
  border-radius: 7px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes breathe {
  50% { transform: scale(1.06); }
}

/* 移动端 */
@media (max-width: 850px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .side-column {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar-inner, .page {
    width: min(100% - 20px, 1160px);
  }
  .topbar-inner {
    min-height: 58px;
    gap: 8px;
  }
  .header-members,
  .account-button > span:last-child {
    display: none;
  }
  .top-actions {
    margin-left: auto;
  }
  .account-button {
    width: 42px;
    padding: 4px;
  }
  .icon-button {
    width: 37px;
    height: 37px;
  }
  .page {
    margin-top: 12px;
  }
  .hero {
    min-height: 190px;
    background-position: 58% center;
  }
  .hero-content {
    padding: 20px;
  }
  .hero h1 {
    font-size: 32px;
  }
  .hero-content > p:not(.hero-label) {
    max-width: 80%;
  }
  .content-layout {
    margin-top: 14px;
    gap: 15px;
  }
  .side-column {
    grid-template-columns: 1fr;
  }
  .composer, .message {
    padding: 15px;
  }
  .announcement {
    padding: 14px;
  }
  .announcement-heading {
    display: grid;
    gap: 2px;
  }
  .message-avatar {
    width: 39px;
    height: 39px;
  }
  .dialog-panel {
    padding: 18px;
  }
  .avatar-choices {
    gap: 6px;
  }
}
