* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
}

/* 认证页面 */
.auth-container {
  max-width: 400px;
  margin: 100px auto;
  background: white;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-container h1 {
  text-align: center;
  color: #667eea;
  margin-bottom: 30px;
}

.auth-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f0f0f0;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.3s;
}

.tab-btn.active {
  background: #667eea;
  color: white;
}

.auth-form input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

.auth-form button {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.3s;
}

.auth-form button:hover {
  background: #5568d3;
}

/* 主页面 */
header {
  background: white;
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
  color: #667eea;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.user-info button {
  padding: 8px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.container {
  display: flex;
  max-width: 1400px;
  margin: 20px auto;
  gap: 20px;
  padding: 0 20px;
}

.sidebar {
  width: 300px;
  background: white;
  padding: 20px;
  border-radius: 10px;
  height: fit-content;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-bottom: 20px;
  font-size: 16px;
}

.project-item {
  padding: 15px;
  margin-bottom: 10px;
  background: #f8f9fa;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s;
  color: #333;
}

.project-item:hover {
  background: #e9ecef;
  transform: translateX(5px);
}

.project-item.active {
  background: #667eea;
  color: white;
}

.project-item .project-meta {
  font-size: 12px;
  color: #666;
  margin-top: 5px;
}

.project-item.active .project-meta {
  color: rgba(255, 255, 255, 0.8);
}

.main-content {
  flex: 1;
  background: white;
  padding: 30px;
  border-radius: 10px;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid #f0f0f0;
  flex-wrap: wrap;
  gap: 10px;
}

.project-header h2 {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.project-header > div {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.project-header button {
  padding: 10px 20px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 10px;
  transition: all 0.3s;
  font-size: 14px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.project-header button:hover {
  background: #5568d3;
}

.project-header button:active {
  transform: scale(0.98);
}

.project-header button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-content {
  padding: 20px 0;
}

/* 日历 */
.calendar-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.calendar-controls button {
  padding: 8px 16px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  position: relative;
}

.calendar-day.header {
  font-weight: bold;
  background: #f8f9fa;
}

.calendar-day.checked {
  background: #d4edda;
  border-color: #28a745;
}

.calendar-day .avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 5px;
}

.calendar-day .avatars img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

#streak-info {
  text-align: center;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  font-size: 18px;
}

/* 排行榜 */
.ranking-item {
  display: flex;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background: #f8f9fa;
  border-radius: 5px;
}

.ranking-item img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 15px;
}

.ranking-item .rank {
  font-size: 24px;
  font-weight: bold;
  margin-right: 15px;
  color: #667eea;
  min-width: 40px;
}

.ranking-item .info {
  flex: 1;
}

.ranking-item .count {
  font-size: 20px;
  font-weight: bold;
  color: #28a745;
}

/* 消息 */
.message-form {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.message-form select,
.message-form textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.message-form textarea {
  min-height: 80px;
  resize: vertical;
}

.message-form button {
  padding: 10px 30px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.3s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.message-form button:hover {
  background: #5568d3;
}

.message-form button:active {
  transform: scale(0.98);
}

.message-form button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.message-item {
  padding: 15px;
  margin-bottom: 10px;
  background: #f8f9fa;
  border-radius: 5px;
  border-left: 4px solid #667eea;
}

.message-item.unread {
  background: #e7f3ff;
  border-left-color: #007bff;
}

.message-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.message-header img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: 10px;
}

.message-time {
  color: #999;
  font-size: 12px;
  margin-left: auto;
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  overflow-y: auto;
}

.modal-content {
  background: white;
  margin: 100px auto;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  border-radius: 10px;
  position: relative;
  z-index: 1001;
}

.close {
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 28px;
  cursor: pointer;
  color: #999;
  z-index: 1002;
  line-height: 1;
  transition: color 0.3s;
}

.close:hover {
  color: #333;
}

.modal-content h2 {
  margin-bottom: 20px;
  color: #667eea;
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

.modal-content textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.modal-content button {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.3s;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.modal-content button:hover {
  background: #5568d3;
}

.modal-content button:active {
  transform: scale(0.98);
}

.modal-content form {
  position: relative;
  z-index: 1;
}


/* 移动端适配 */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  /* 认证页面 */
  .auth-container {
    margin: 20px auto;
    padding: 20px;
    width: 95%;
  }

  .auth-container h1 {
    font-size: 24px;
    margin-bottom: 20px;
  }

  /* 主页面头部 */
  header {
    padding: 15px 20px;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  header h1 {
    font-size: 20px;
  }

  .user-info {
    width: 100%;
    justify-content: space-between;
  }

  .user-info img {
    width: 35px;
    height: 35px;
  }

  .user-info button {
    padding: 6px 15px;
    font-size: 14px;
  }

  /* 容器布局 */
  .container {
    flex-direction: column;
    padding: 10px;
    gap: 15px;
  }

  .sidebar {
    width: 100%;
    padding: 15px;
  }

  .main-content {
    padding: 15px;
  }

  /* 项目列表 */
  .project-item {
    padding: 12px;
    font-size: 14px;
  }

  /* 项目头部 */
  .project-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .project-header h2 {
    font-size: 18px;
  }

  .project-header button {
    width: 100%;
    margin-left: 0;
  }

  /* 标签页 */
  .tabs {
    flex-wrap: wrap;
    gap: 5px;
  }

  .tab-btn {
    flex: 1;
    min-width: 80px;
    font-size: 14px;
    padding: 8px;
  }

  /* 日历 */
  .calendar-controls {
    flex-wrap: wrap;
    gap: 10px;
  }

  .calendar-controls span {
    font-size: 16px;
  }

  .calendar-controls button {
    padding: 6px 12px;
    font-size: 14px;
  }

  #calendar {
    gap: 5px;
  }

  .calendar-day {
    padding: 5px;
    font-size: 12px;
    min-height: 50px;
  }

  .calendar-day .avatars img {
    width: 16px;
    height: 16px;
  }

  #streak-info {
    padding: 15px;
    font-size: 16px;
  }

  #streak-info > div:first-child {
    font-size: 20px !important;
  }

  /* 排行榜 */
  .ranking-item {
    padding: 12px;
    flex-wrap: wrap;
  }

  .ranking-item img {
    width: 40px;
    height: 40px;
  }

  .ranking-item .rank {
    font-size: 20px;
    min-width: 35px;
  }

  .ranking-item .count {
    font-size: 18px;
  }

  /* 消息表单 */
  .message-form {
    padding: 15px;
  }

  .message-form select,
  .message-form textarea {
    font-size: 14px;
  }

  .message-form button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }

  .message-item {
    padding: 12px;
    font-size: 14px;
  }

  .message-header img {
    width: 25px;
    height: 25px;
  }

  /* 弹窗 */
  .modal-content {
    margin: 20px auto;
    padding: 20px;
    width: 95%;
  }

  .modal-content h2 {
    font-size: 20px;
    margin-bottom: 15px;
  }

  .close {
    right: 15px;
    top: 15px;
    font-size: 24px;
  }

  /* 按钮 */
  .btn-primary {
    padding: 10px;
    font-size: 15px;
  }
}

/* 小屏幕手机 */
@media (max-width: 480px) {
  .auth-container h1 {
    font-size: 20px;
  }

  header h1 {
    font-size: 18px;
  }

  .project-header h2 {
    font-size: 16px;
  }

  #calendar {
    gap: 3px;
  }

  .calendar-day {
    padding: 3px;
    font-size: 11px;
    min-height: 45px;
  }

  .calendar-day .avatars img {
    width: 14px;
    height: 14px;
  }

  .tab-btn {
    font-size: 13px;
    padding: 6px;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .tab-btn,
  .project-item,
  .ranking-item,
  .message-item,
  button {
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
  }

  button:active,
  .tab-btn:active,
  .project-item:active {
    transform: scale(0.98);
  }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    flex-direction: row;
  }

  .sidebar {
    width: 250px;
  }

  header {
    flex-direction: row;
    align-items: center;
  }

  .user-info {
    width: auto;
  }
}


/* 加载动画 */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.3;
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 选择文本样式 */
::selection {
  background: #667eea;
  color: white;
}

::-moz-selection {
  background: #667eea;
  color: white;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

/* 输入框焦点样式 */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 禁用状态 */
button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 过渡动画 */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 消息未读标记 */
.message-item.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #ff4757;
  border-radius: 50%;
  margin-left: -4px;
}

.message-item {
  position: relative;
}

/* 成功/错误提示优化 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 15px 30px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 9999;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.toast.success {
  border-left: 4px solid #28a745;
}

.toast.error {
  border-left: 4px solid #dc3545;
}


/* 欢迎消息样式 */
#welcome-message {
  animation: fadeIn 0.5s ease-in;
}

#welcome-message h2 {
  font-size: 28px;
}

#welcome-message p {
  font-size: 16px;
  line-height: 1.8;
}

/* 加入项目提示样式 */
.join-prompt {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.5s ease-in;
}

.join-prompt button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4) !important;
}

/* 项目成员标记 */
.project-meta span {
  font-weight: 600;
}

/* 移动端欢迎消息优化 */
@media (max-width: 768px) {
  #welcome-message {
    padding: 40px 15px;
  }

  #welcome-message h2 {
    font-size: 22px;
  }

  #welcome-message p {
    font-size: 14px;
  }

  .join-prompt {
    padding: 40px 15px;
  }

  .join-prompt button {
    width: 100%;
    max-width: 300px;
  }
}
