body {
  font-family: 'Noto Sans JP', '游ゴシック', 'Yu Gothic', sans-serif;
  background: #f8f9fa;
  color: #222;
  margin: 0;
  padding: 0;
  -webkit-overflow-scrolling: touch; /* iOS滚动优化 */
}
.container {
  max-width: 900px;
  margin: 40px auto 0 auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 32px 24px 24px 24px;
}
header h1 {
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 24px;
  text-align: center;
}
.tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.tab {
  background: none;
  border: none;
  font-size: 1.1em;
  padding: 10px 32px;
  margin: 0 8px;
  border-radius: 18px 18px 0 0;
  cursor: pointer;
  color: #888;
  transition: background 0.2s, color 0.2s;
}
.tab.active {
  background: #e3eaf1;
  color: #1a4d7a;
  font-weight: bold;
}
#todo-list {
  margin-bottom: 32px;
}
.todo-item {
  background: #f5f7fa;
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  border-left: 6px solid #b5c9d6;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  /* 只加自身阴影和背景 */
}
.todo-main {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 8px;
}
.todo-time-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.95em;
  color: #b0b8c1;
  min-width: 110px;
}
.todo-item[data-priority="high"] {
  border-left-color: #e57373;
}
.todo-item[data-priority="medium"] {
  border-left-color: #ffd54f;
}
.todo-item[data-priority="low"] {
  border-left-color: #81c784;
}
.todo-item.completed {
  opacity: 0.6;
  text-decoration: line-through;
  background: #e9ecef;
  /* 只影响当前卡片 */
}
.todo-title {
  font-size: 1.05em;
  font-weight: 500;
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.todo-desc {
  font-size: 0.97em;
  color: #6a7b8a;
  margin-left: 28px;
  margin-top: 2px;
  min-height: 1.2em;
}
.todo-meta {
  font-size: 0.92em;
  color: #b0b8c1;
  margin-bottom: 4px;
}
.todo-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 8px;
}
.todo-actions > div {
  display: flex;
  gap: 4px;
}
.todo-actions button {
  background: none;
  border: none;
  color: #1a4d7a;
  margin: 0;
  cursor: pointer;
  font-size: 1.1em;
  border-radius: 6px;
  padding: 2px 6px;
  transition: background 0.2s;
  line-height: 1;
}
.todo-actions button:hover {
  background: #e3eaf1;
}
.collapse-btn {
  font-size: 1.1em;
  margin-right: 4px;
  user-select: none;
  width: 1.2em;
  display: inline-block;
  text-align: center;
}
.todo-children {
  margin-left: 32px;
  border-left: 2px dashed #e3eaf1;
  padding-left: 8px;
  margin-top: 4px;
  margin-bottom: 0;
  background: none;
  box-shadow: none;
  max-width: calc(100% - 40px);
}
.todo-children-container {
  width: 100%;
  margin-top: 4px;
}
.todo-form-container {
  margin-left: 32px;
  margin-top: 4px;
}
.todo-item[data-level="2"] {
  /* 可选：略微浅色区分 */
  background: #f7fafc;
}
.todo-item[data-level="3"] {
  background: #f9fbfd;
}
#add-todo {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
#add-todo input, #add-todo select {
  font-size: 1em;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  background: #f8f9fa;
  outline: none;
}
#add-todo-btn {
  background: #1a4d7a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
}
#add-todo-btn:hover {
  background: #14508a;
}
#sync-btn {
  display: block;
  margin: 0 auto;
  background: #ffd54f;
  color: #1a4d7a;
  border: none;
  border-radius: 10px;
  padding: 8px 32px;
  font-size: 1.05em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: background 0.2s;
}
#sync-btn:hover {
  background: #ffe082;
}
.inline-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.inline-form input, .inline-form select {
  font-size: 0.98em;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #d0d7de;
  background: #f8f9fa;
  outline: none;
}
.inline-form button {
  background: #1a4d7a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.98em;
  cursor: pointer;
  transition: background 0.2s;
}
.inline-form button.cancel-btn {
  background: #b0b8c1;
  color: #fff;
}
.inline-form button:hover {
  background: #14508a;
}

/* GitHub 配置区域样式 */
.github-config {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.token-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}

.token-input-group label {
  font-size: 0.9em;
  font-weight: 500;
  color: #1a4d7a;
  margin-bottom: 2px;
}

.token-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.token-input-group input {
  font-size: 0.95em;
  padding: 6px 10px;
  padding-right: 30px;
  border-radius: 6px;
  border: 1px solid #d0d7de;
  background: #f8f9fa;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.token-input-group input:focus {
  border-color: #1a4d7a;
  background: #fff;
}

#clear-token-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.2s, background 0.2s;
}

#clear-token-btn:hover {
  color: #666;
  background: #f0f0f0;
}

.token-input-group small {
  font-size: 0.8em;
  color: #6a7b8a;
  margin-top: 2px;
}

#sync-btn {
  display: inline-block;
  margin: 0;
  background: #ffd54f;
  color: #1a4d7a;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: background 0.2s;
  white-space: nowrap;
}

#sync-btn:hover {
  background: #ffe082;
}

#sync-btn:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

#sync-status {
  text-align: center;
  font-size: 0.9em;
  margin-top: 8px;
  min-height: 1.2em;
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    padding: 8px 12px 8px 12px;
  }
  
  header h1 {
    font-size: 1.2em;
    margin-bottom: 8px;
  }
  
  .github-config {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  
  .token-input-group {
    min-width: 150px;
  }
  
  #add-todo {
    flex-direction: row;
    gap: 8px;
  }
  
  #add-todo input, #add-todo select {
    flex: 1;
  }
  
  #add-todo-btn {
    flex-shrink: 0;
  }
}

/* 手机端响应式设计 */
@media (max-width: 768px) {
  /* 确保触摸友好的最小尺寸 */
  button, input, select {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 增加触摸区域 */
  .todo-actions button {
    min-width: 44px;
    min-height: 44px;
  }
  
  .container {
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    padding: 16px 12px 12px 12px;
    box-shadow: none;
  }
  
  header h1 {
    font-size: 1.5em;
    margin-bottom: 16px;
  }
  
  /* GitHub 配置区域在手机端垂直排列 */
  .github-config {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
  }
  
  .token-input-group {
    min-width: auto;
  }
  
  #sync-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1.1em;
  }
  
  /* 标签页在手机端调整 */
  .tabs {
    margin-bottom: 16px;
  }
  
  .tab {
    padding: 8px 20px;
    margin: 0 4px;
    font-size: 1em;
  }
  
  /* 添加任务区域在手机端垂直排列 */
  #add-todo {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
  }
  
  #add-todo input, #add-todo select {
    padding: 10px 12px;
    font-size: 1em;
  }
  
  #add-todo-btn {
    padding: 12px 20px;
    font-size: 1.1em;
  }
  
  /* 待办事项卡片在手机端的布局调整 */
  .todo-main {
    flex-direction: column;
    gap: 8px;
    padding: 16px 12px;
  }
  
  /* 标题和描述在手机端分2行显示 */
  .todo-main .todo-title {
    max-width: none;
    white-space: normal;
    word-break: break-word;
    margin-right: 0;
    display: block;
    margin-bottom: 4px;
  }
  
  .todo-main .todo-desc {
    margin-left: 0;
    margin-top: 0;
    color: #6a7b8a;
    font-size: 0.95em;
    display: block;
  }
  
  /* 时间信息在手机端右侧显示 */
  .todo-time-info {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    min-width: auto;
    width: auto;
    font-size: 0.85em;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    margin-left: 0;
    margin-bottom: 0;
  }
  
  /* 操作按钮在手机端横排显示在时间下方 */
  .todo-actions {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    margin-left: 0;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e3eaf1;
  }
  
  .todo-actions > div {
    gap: 8px;
  }
  
  .todo-actions button {
    font-size: 1.2em;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
  }
  
  /* 子任务在手机端的缩进调整 */
  .todo-children {
    margin-left: 16px;
  }
  
  .todo-form-container {
    margin-left: 16px;
  }
  
  /* 内联表单在手机端垂直排列 */
  .inline-form {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .inline-form input, .inline-form select {
    padding: 8px 10px;
    font-size: 1em;
  }
  
  .inline-form button {
    padding: 8px 12px;
    font-size: 1em;
  }
  
  /* 统计信息在手机端调整 */
  #todo-stats {
    font-size: 0.9em;
    margin-bottom: 8px;
  }
  
  /* 手机端字体大小优化 */
  body {
    font-size: 16px; /* 防止iOS缩放 */
  }
  
  /* 手机端滚动优化 */
  .todo-item {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* 手机端标题行优化 */
  .todo-main > div:first-child {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  /* 手机端优先级图标优化 */
  .todo-main .todo-title {
    flex: 1;
    min-width: 0;
  }
  
  /* 手机端按钮反馈优化 */
  .todo-actions button:active {
    background: #cce7ff;
    transform: scale(0.95);
  }
  
  #add-todo-btn:active {
    background: #0d3d6b;
    transform: scale(0.98);
  }
  
  .tab:active {
    background: #d1e7f0;
  }
}

/* 超小屏幕设备的额外优化 */
@media (max-width: 480px) {
  .container {
    padding: 12px 8px 8px 8px;
  }
  
  header h1 {
    font-size: 1.3em;
    margin-bottom: 12px;
  }
  
  .tab {
    padding: 6px 16px;
    font-size: 0.9em;
  }
  
  .todo-main {
    padding: 10px 6px;
  }
  
  .todo-actions button {
    font-size: 1.1em;
    padding: 4px 6px;
  }
  
  .todo-time-info {
    font-size: 0.8em;
  }
  
  /* 在超小屏幕上隐藏一些次要信息 */
  .created-time {
    display: none;
  }
}