:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --bg-top: #f0f2f3;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f8f9fa;
  --text: #102119;
  --muted: #56635d;
  --muted-strong: #35423c;
  --line: #dfe4e1;
  --line-strong: #b8c2bd;
  --accent: #0d765c;
  --accent-hover: #095f4a;
  --accent-strong: #064637;
  --project: #0d765c;
  --settlement: #286f96;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --warning: #94620c;
  --warning-soft: #fff7e6;
  --success: #0d765c;
  --success-soft: #e7f5ef;
  --focus: rgba(13, 118, 92, 0.22);
  --radius: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 33, 25, 0.04);
  --shadow-panel: 0 6px 12px rgba(16, 33, 25, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 750;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
  transform: none;
}

.page {
  min-height: 100vh;
}

.page::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 156px;
  background: var(--bg-top);
  border-bottom: 1px solid #e5e9e6;
  pointer-events: none;
  z-index: -1;
}

.app-frame {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar,
.content-shell,
.dashboard,
.login-panel {
  width: 100%;
}

.topbar {
  padding: 28px 0 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.topbar h1,
.panel-title h1 {
  margin: 6px 0 0;
  font-size: 2rem;
  line-height: 1.18;
  letter-spacing: 0;
  text-wrap: balance;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0;
}

.page-subtitle {
  max-width: 64ch;
  margin: 9px 0 0;
  color: var(--muted);
  text-wrap: pretty;
}

.contact-note {
  margin-top: 4px;
  color: var(--muted-strong);
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 999px;
  padding: 0 13px;
  white-space: nowrap;
}

.live-status span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
}

.live-status b {
  font-size: 0.875rem;
  font-weight: 750;
}

.live-status.connected {
  color: var(--accent-strong);
  border-color: #a9d8c9;
  background: var(--success-soft);
}

.live-status.connected span {
  background: var(--success);
}

.live-status.disconnected {
  color: var(--warning);
  border-color: #ead19b;
  background: var(--warning-soft);
}

.user-sections {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(330px, 0.92fr);
  align-items: start;
  gap: 18px;
  padding-bottom: 44px;
}

.admin-sections {
  grid-column: 1 / -1;
  width: 100%;
  padding-bottom: 0;
}

.content-shell,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.content-shell {
  --section-accent: var(--project);
  padding: 18px;
}

.settlement-shell {
  --section-accent: var(--settlement);
}

.project-shell {
  --section-accent: var(--project);
}

.feed-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 14px;
  margin-bottom: 14px;
}

.feed-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 1.1875rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.feed-head h2::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--section-accent, var(--accent));
}

.feed-head p {
  margin: 0;
}

.feed-note {
  margin-top: 3px !important;
  color: var(--muted);
  font-size: 0.875rem;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted-strong);
  padding: 0 10px;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}

.post-list {
  display: grid;
  gap: 10px;
  padding-bottom: 2px;
}

.settlement-shell {
  min-height: 320px;
}

.post-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.post-card:hover {
  border-color: var(--line-strong);
  background: #ffffff;
  transform: translateY(-1px);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}

.post-meta::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--section-accent, var(--accent));
  opacity: 0.78;
}

.post-card time {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}

.post-card p {
  max-width: 75ch;
  margin: 0;
  color: var(--text);
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  min-height: 178px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}

.empty.error-state {
  color: var(--danger);
  border-color: #e7aaa2;
  background: var(--danger-soft);
}

.skeleton-card {
  height: 116px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent),
    linear-gradient(#e3ebe7 16px, transparent 0),
    linear-gradient(#eef4f1 44px, transparent 0),
    var(--surface-muted);
  background-size: 160px 100%, 170px 16px, 78% 44px, 100% 100%;
  background-position: -160px 0, 18px 18px, 18px 51px, 0 0;
  background-repeat: no-repeat;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-card.compact {
  height: 92px;
}

.admin-layout {
  padding: 32px 0 48px;
}

.login-panel {
  max-width: 480px;
  padding: 30px;
  margin: 8vh auto 0;
  box-shadow: var(--shadow-panel);
}

.panel-title {
  margin-bottom: 22px;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.form-stack {
  display: grid;
  gap: 15px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 750;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--section-accent, var(--accent));
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #5e7168;
}

input:hover,
textarea:hover {
  border-color: #93a89e;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
  outline: none;
}

textarea {
  min-height: 178px;
  resize: vertical;
  line-height: 1.65;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.form-message.error {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.admin-topbar {
  grid-column: 1 / -1;
  padding-top: 0;
  padding-bottom: 2px;
}

.ghost-button,
.delete-button {
  background: var(--surface);
  color: var(--accent-strong);
  border: 1px solid var(--line-strong);
}

.ghost-button:hover {
  background: var(--surface-muted);
  color: var(--accent-strong);
}

.admin-panel:focus-within {
  border-color: color-mix(in srgb, var(--section-accent) 38%, var(--line));
}

.composer-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.composer-actions > div {
  display: grid;
  gap: 6px;
}

.action-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.admin-panel .post-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}

.admin-list-block {
  display: grid;
  gap: 10px;
}

.list-title {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.875rem;
  font-weight: 800;
}

.delete-button {
  min-height: 36px;
  color: var(--danger);
  padding: 0 13px;
}

.delete-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

@keyframes shimmer {
  to {
    background-position: calc(100% + 160px) 0, 18px 18px, 18px 51px, 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 820px) {
  .app-frame {
    width: min(100% - 24px, 1180px);
  }

  .user-sections,
  .dashboard {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .topbar,
  .feed-head,
  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding-top: 24px;
    gap: 16px;
  }

  .topbar h1,
  .panel-title h1 {
    font-size: 1.625rem;
  }

  .live-status,
  .feed-head .count-pill {
    width: fit-content;
  }

  .content-shell,
  .login-panel {
    padding: 16px;
  }

  .login-panel {
    margin-top: 4vh;
  }

  .composer-actions button,
  .login-panel button {
    width: 100%;
  }

  .admin-panel .post-card {
    grid-template-columns: 1fr;
  }

  .delete-button {
    width: fit-content;
  }
}
