:root {
  --primary: #4f6ef7;
  --primary-dark: #3b54d6;
  --primary-light: #eef1fe;
  --accent: #14b8a6;
  --text: #1e293b;
  --text-light: #64748b;
  --text-lighter: #94a3b8;
  --border: #e8ecf3;
  --bg: #f5f7fb;
  --card: #ffffff;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 4px 20px rgba(30, 41, 59, 0.06);
  --shadow-hover: 0 8px 30px rgba(79, 110, 247, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============ 顶部导航 ============ */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(8px);
}

.navbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
}

.nav-link {
  font-size: 14px;
  color: var(--text-light);
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* ============ 容器 ============ */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ============ Hero ============ */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-light);
  font-size: 16px;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 32px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}

/* ============ 表单 ============ */
.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

label .optional {
  color: var(--text-lighter);
  font-weight: 400;
  font-size: 12px;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  transition: all 0.2s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 110, 247, 0.3);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--border);
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ============ 留言卡片 ============ */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: all 0.2s;
}

.message-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: transparent;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.author-info .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.author-info .time {
  font-size: 12px;
  color: var(--text-lighter);
}

.message-content {
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.reply-block {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 10px 10px 0;
}

.reply-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.reply-text {
  font-size: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

/* ============ 空状态 ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-lighter);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 15px;
}

/* ============ Toast 提示 ============ */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--text);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

/* ============ 后台登录 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef1fe 0%, #f5f7fb 50%, #e6fbf7 100%);
}

.login-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(30, 41, 59, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 8px;
  font-size: 20px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 28px;
}

/* ============ 后台管理 ============ */
.admin-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-title {
  font-size: 16px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-light);
}

.stats span b {
  color: var(--primary);
  font-size: 15px;
}

.admin-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============ 后台留言项 ============ */
.admin-message {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 14px;
}

.admin-message-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
}

.admin-message-meta .name {
  font-weight: 600;
  font-size: 15px;
}

.admin-message-meta .sub {
  font-size: 12px;
  color: var(--text-lighter);
  margin-top: 2px;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}

.tag-featured {
  background: #dcfce7;
  color: #15803d;
}

.tag-replied {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag-pending {
  background: #fef3c7;
  color: #b45309;
}

.admin-message-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 12px;
}

.admin-reply-preview {
  font-size: 13px;
  color: var(--text-light);
  background: var(--primary-light);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.reply-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: none;
}

.reply-form.show {
  display: block;
}

.reply-form textarea {
  margin-bottom: 10px;
}

/* ============ 加载 ============ */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-lighter);
  font-size: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============ 响应式 ============ */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 24px 16px 60px;
  }
  .card {
    padding: 22px;
  }
  .hero h1 {
    font-size: 26px;
  }
  .admin-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .admin-message-top {
    flex-direction: column;
  }
}

/* ============ 站点备案 Footer ============ */
.site-footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  text-align: center;
  border-top: 1px solid var(--border);
  color: var(--text-lighter);
  font-size: 12.5px;
  line-height: 1.9;
}

.site-footer .beian-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 16px;
}

.site-footer a {
  color: var(--text-lighter);
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--primary);
}

.site-footer .beian-sep {
  color: var(--border);
}

.site-footer .ga-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 4px;
}

/* 后台管理页 footer 与容器对齐 */
.admin-container + .site-footer,
#adminPage .site-footer {
  max-width: 1000px;
  padding-top: 28px;
}

@media (max-width: 640px) {
  .site-footer {
    padding: 20px 16px 32px;
  }
}
