* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  min-height: 100vh;
  color: #333;
  /* 滚动优化 */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
  /* 禁用橡皮筋效果 */
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: #006341;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 99, 65, 0.2);
  border-top: 4px solid #006341;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.selection-page {
  min-height: 100vh;
  padding-bottom: clamp(2rem, 8vw, 3rem);
}

.header {
  text-align: center;
  margin-bottom: clamp(1.5rem, 8vw, 2.5rem);
  padding: clamp(1.5rem, 8vw, 2.5rem) 1.25rem 0;
}

.logo {
  width: clamp(60px, 15vw, 80px);
  height: clamp(60px, 15vw, 80px);
  margin-bottom: 1.25rem;
  border-radius: 50%;
  box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.2);
}

.header h1 {
  color: #006341;
  font-size: clamp(1.5rem, 5vw, 1.75rem);
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-shadow: 0 0.063rem 0.125rem rgba(255, 255, 255, 0.8);
}

.header .subtitle {
  color: #666;
  font-size: clamp(0.875rem, 3.5vw, 1rem);
  font-weight: 300;
}

.cards-container {
  max-width: 37.5rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 4vw, 1.25rem);
  /* 滚动性能优化 */
  will-change: transform;
}

.device-card {
  background: linear-gradient(145deg, #ffffff, #f8fffe);
  border-radius: clamp(1rem, 4vw, 1.25rem);
  padding: clamp(1.25rem, 5vw, 1.75rem);
  min-height: clamp(5rem, 15vw, 6rem);
  box-shadow: 
    0 0.5rem 2rem rgba(0, 99, 65, 0.12),
    0 0.25rem 1rem rgba(0, 0, 0, 0.08),
    inset 0 0.063rem 0 rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 0.063rem solid rgba(0, 99, 65, 0.1);
  /* 移动端触摸优化 */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  /* 弹性布局 */
  display: flex;
  flex-direction: column;
}

.device-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: clamp(0.25rem, 1.5vw, 0.375rem);
  background: linear-gradient(135deg, #006341 0%, #00754a 50%, #228B22 100%);
  border-radius: clamp(1rem, 4vw, 1.25rem) clamp(1rem, 4vw, 1.25rem) 0 0;
}

.device-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(0, 99, 65, 0.03) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

/* 移动端触摸反馈 */
.device-card:active {
  transform: translateY(-2px) scale(0.98);
  box-shadow: 
    0 4px 16px rgba(0, 99, 65, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.card-content {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 4vw, 1.25rem);
  flex: 1;
  min-height: 0;
}

.device-icon {
  width: clamp(3.5rem, 12vw, 4rem);
  height: clamp(3.5rem, 12vw, 4rem);
  background: linear-gradient(135deg, #006341 0%, #00754a 50%, #228B22 100%);
  border-radius: clamp(0.75rem, 3vw, 1rem);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 
    0 0.375rem 1.25rem rgba(0, 99, 65, 0.25),
    0 0.125rem 0.5rem rgba(0, 0, 0, 0.1),
    inset 0 0.063rem 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}



.device-icon::after {
  content: '🎵';
  font-size: clamp(1.5rem, 5vw, 1.75rem);
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0.063rem 0.125rem rgba(0, 0, 0, 0.2));
}

.device-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.device-name {
  font-size: clamp(1.125rem, 4.5vw, 1.25rem);
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(135deg, #2d2d2d, #006341);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.device-id {
  font-size: clamp(0.75rem, 3vw, 0.8125rem);
  color: #666;
  margin-bottom: 0.25rem;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  background: rgba(0, 99, 65, 0.05);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  display: inline-block;
  font-weight: 500;
}

.device-remark {
    margin-top: 0.3rem;
  font-size: clamp(0.8125rem, 3.5vw, 0.875rem);
  color: #777;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /*font-style: italic;*/
}

.card-arrow {
  width: clamp(2rem, 6vw, 2.5rem);
  height: clamp(2rem, 6vw, 2.5rem);
  background: #006341;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  transform: translateX(0);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 99, 65, 0.3);
  flex-shrink: 0;
  position: relative;
}

.card-arrow::before {
  content: '';
  width: 0;
  height: 0;
  border-left: clamp(0.5rem, 2vw, 0.625rem) solid white;
  border-top: clamp(0.375rem, 1.5vw, 0.5rem) solid transparent;
  border-bottom: clamp(0.375rem, 1.5vw, 0.5rem) solid transparent;
  margin-left: 0.125rem;
}

.device-card:active .card-arrow {
  transform: translateX(4px) scale(1.05);
  background: #00754a;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 99, 65, 0.4);
}

.single-device {
  animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* 超小屏幕适配 (320px - 480px) */
@media (max-width: 30rem) {
  .selection-page {
    padding-bottom: 2rem;
  }
  
  .header {
    padding: 1.5rem 1rem 0;
    margin-bottom: 1.5rem;
  }
  
  .cards-container {
    padding: 0 1rem;
    gap: 0.875rem;
  }
  
  .device-card {
    padding: 1rem 1.25rem;
    min-height: 4.5rem;
  }
  
  .card-content {
    gap: 0.875rem;
  }
  
  .device-card::before {
    height: 0.25rem;
  }
}

/* 小屏幕适配 (481px - 768px) */
@media (min-width: 30.063rem) and (max-width: 48rem) {
  .cards-container {
    max-width: 32rem;
  }
  
  .device-card {
    padding: 1.375rem 1.5rem;
  }
}

/* 大屏幕适配 (769px+) */
@media (min-width: 48.063rem) {
  .cards-container {
    max-width: 40rem;
    gap: 1.375rem;
  }
  
  .device-card {
    padding: 1.75rem 2rem;
    min-height: 6.5rem;
  }
  
  .card-content {
    gap: 1.5rem;
  }
  
  .device-card:hover {
    transform: translateY(-0.125rem);
    box-shadow: 
      0 0.75rem 2.5rem rgba(0, 99, 65, 0.15),
      0 0.375rem 1.25rem rgba(0, 0, 0, 0.1);
  }
}

/* 超宽屏适配 (1024px+) */
@media (min-width: 64rem) {
  .header {
    padding: 3rem 1.25rem 0;
    margin-bottom: 3rem;
  }
  
  .cards-container {
    max-width: 42rem;
  }
}

/* 备注功能样式 */
.remark-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  background: rgba(0, 99, 65, 0.1);
  border: none;
  border-radius: 50%;
  font-size: 0.875rem;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.remark-btn:hover {
  background: rgba(0, 99, 65, 0.2);
  transform: scale(1.1);
}

.remark-btn:active {
  background: rgba(0, 99, 65, 0.3);
  transform: scale(0.95);
}

.remark-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 99, 65, 0.1);
  animation: slideDown 0.3s ease-out;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.remark-input {
  flex: 1;
  height: 2.125rem;
  padding: 0 0.75rem;
  border: 2px solid rgba(0, 99, 65, 0.2);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  transition: border-color 0.2s ease;
  background: #fafffe;
  line-height: calc(2.125rem - 4px);
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.remark-input::-webkit-scrollbar {
  display: none;
}

.remark-input:focus {
  outline: none;
  border-color: #006341;
  box-shadow: 0 0 0 3px rgba(0, 99, 65, 0.1);
}

.remark-input::placeholder {
  color: #999;
}

.remark-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}

.remark-save-btn,
.remark-cancel-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 4rem;
  -webkit-tap-highlight-color: transparent;
}

.remark-save-btn {
  background: #006341;
  color: white;
}

.remark-save-btn:hover {
  background: #00754a;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 99, 65, 0.3);
}

.remark-save-btn:active {
  background: #004d31;
  transform: translateY(0);
}

.remark-save-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.remark-cancel-btn {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #ddd;
}

.remark-cancel-btn:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.remark-cancel-btn:active {
  background: #dee2e6;
  transform: translateY(0);
}

/* 移动端备注样式优化 */
@media (max-width: 30rem) {
  .remark-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
  }
  
  .remark-input {
    min-height: auto;
    height: 2rem;
    padding: 0.4375rem 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.2;
  }

  .remark-actions {
    flex-direction: row;
    gap: 0.5rem;
  }

  .remark-save-btn,
  .remark-cancel-btn {
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    min-width: 3.5rem;
    height: 2rem;
    line-height: 1.2;
  }
}

/* Toast 通知样式 */
.toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.toast {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-width: 180px;
  text-align: center;
  word-wrap: break-word;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: rgba(0, 99, 65, 0.9);
}

.toast.error {
  background: rgba(220, 53, 69, 0.9);
}

.toast.warning {
  background: rgba(255, 193, 7, 0.9);
  color: #333;
}

.toast-icon {
  display: inline-block;
  margin-right: 6px;
  font-weight: bold;
  font-size: 16px;
}

/* 移动端 Toast 适配 */
@media (max-width: 30rem) {
  .toast-container {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 48px);
  }

  .toast {
    max-width: 160px;
    font-size: 13px;
    padding: 10px 16px;
  }
}