/* ========== 基础样式 ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* 主色调 */
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;

  /* 辅助色 */
  --secondary-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;

  /* 中性色 */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border-color: #e5e7eb;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;

  /* 阴影 */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* 间距 */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

body {
  margin: 0;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--text-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(138, 43, 226, 0.2), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  position: relative;
  z-index: 1;
}

/* ========== 头部样式 ========== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-md) var(--spacing-lg);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

#auth {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

#auth button {
  margin-left: 0;
}

#user {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

/* ========== 按钮样式 ========== */
button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  outline: none;
}

button:not(.btn-vote):not(.del):not(.delimg) {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  box-shadow: var(--shadow-sm);
}

button:not(.btn-vote):not(.del):not(.delimg):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:not(.btn-vote):not(.del):not(.delimg):active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ========== 提示文本 ========== */
.tip {
  color: var(--text-secondary);
  background: var(--bg-primary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.error {
  color: var(--error-color);
  background: #fef2f2;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--error-color);
}

.loading {
  color: var(--text-secondary);
  text-align: center;
  padding: var(--spacing-xl);
  font-size: 16px;
}

/* ========== 卡片样式 ========== */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin: var(--spacing-lg) 0;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.card:hover::before {
  opacity: 1;
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.desc {
  margin: var(--spacing-xs) 0 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.cover {
  margin-top: var(--spacing-md);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cover img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.cover:hover img {
  transform: scale(1.05);
}

/* ========== 投票区域 ========== */
.vote {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.btn-vote {
  padding: 8px 16px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.btn-vote:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.vote-count {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  padding: 4px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-md);
}

/* ========== 评论区域 ========== */
.comments {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.comments h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.comment-form textarea {
  width: 100%;
  resize: vertical;
  padding: var(--spacing-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.3s ease;
  min-height: 80px;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comment-list li {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
  transition: all 0.2s ease;
}

.comment-list li:hover {
  background: var(--bg-tertiary);
  transform: translateX(4px);
}

.comment-list li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.comment-list .time {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: var(--spacing-xs);
}

/* ========== 订阅区域 ========== */
#subscription {
  background: var(--bg-primary);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-lg);
}

#subscription h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-md);
}

#sub-status {
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  font-size: 15px;
}

/* ========== 页脚 ========== */
footer {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-top: var(--spacing-xl);
  text-align: center;
}

footer small {
  color: var(--text-muted);
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease;
}

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

/* ========== 动画效果 ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.card {
  animation: fadeIn 0.5s ease;
}

.btn-vote:active {
  animation: pulse 0.3s ease;
}

/* ========== 加载状态 ========== */
.loading::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ========== 滚动条美化 ========== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--secondary-color));
}

/* ========== 选中文本样式 ========== */
::selection {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* ========== 焦点可见性 ========== */
:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-md);
  }

  header {
    flex-direction: column;
    gap: var(--spacing-md);
    text-align: center;
  }

  header h1 {
    font-size: 20px;
  }

  #auth {
    flex-direction: column;
    width: 100%;
  }

  #auth button {
    width: 100%;
  }

  .comment-form {
    grid-template-columns: 1fr;
  }

  .comment-form button {
    width: 100%;
  }

  .card {
    padding: var(--spacing-md);
  }

  .vote {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  header h1 {
    font-size: 18px;
  }

  .card h2 {
    font-size: 18px;
  }

  button {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* ========== 打印样式 ========== */
@media print {
  body {
    background: white;
  }

  body::before {
    display: none;
  }

  header, footer {
    box-shadow: none;
  }

  .card {
    break-inside: avoid;
  }

  button {
    display: none;
  }
}

