html, body, main, header, footer {
  padding: 0px;
  margin: 0px;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #333;
}

#app-title {
  text-align: center;
  font-size: 28px;
  margin: 0 0 8px 0;
  color: #2c3e50;
}

#app-subtitle {
  text-align: center;
  font-size: 14px;
  color: #7f8c8d;
  margin: 0 0 24px 0;
}

#mode-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid #e0e0e0;
}

.mode-tab {
  flex: 1;
  padding: 12px 20px;
  font-size: 16px;
  border: none;
  background: none;
  color: #7f8c8d;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
}

.mode-tab:hover {
  color: #3498db;
}

.mode-tab.active {
  color: #3498db;
  border-bottom-color: #3498db;
}

#input-area {
  margin-bottom: 20px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.weighted-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.value-input, .weight-input {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid #dcdcdc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.value-input:focus, .weight-input:focus {
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.weight-label {
  font-size: 16px;
  color: #7f8c8d;
  font-weight: 500;
  flex-shrink: 0;
}

.btn-remove {
  width: 36px;
  height: 36px;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  background: #f5f5f5;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  line-height: 1;
}

.btn-remove:hover {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

.input-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-secondary {
  padding: 8px 16px;
  font-size: 14px;
  border: 1px solid #dcdcdc;
  border-radius: 6px;
  background: #f8f9fa;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #e9ecef;
  border-color: #bbb;
}

#decimal-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #555;
}

#decimal-places {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #dcdcdc;
  border-radius: 6px;
  outline: none;
  background: #fff;
  cursor: pointer;
}

#decimal-places:focus {
  border-color: #3498db;
}

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 1px;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2980b9, #21618c);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

#result-area {
  margin-top: 24px;
  padding: 20px;
  background: #f0f7ff;
  border-radius: 10px;
  border: 1px solid #d6eaf8;
  text-align: center;
  animation: resultFadeIn 0.3s ease;
}

@keyframes resultFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#result-title {
  font-size: 14px;
  color: #7f8c8d;
  margin-bottom: 8px;
}

#result-value {
  font-size: 36px;
  font-weight: 700;
  color: #2c3e50;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  word-break: break-all;
}

#result-detail {
  font-size: 13px;
  color: #95a5a6;
  margin-top: 8px;
  margin-bottom: 12px;
}

#copy-result-btn {
  margin-top: 4px;
}

#copy-result-btn.copied {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
}

#history-area {
  margin-top: 32px;
}

#history-title {
  font-size: 16px;
  color: #2c3e50;
  margin: 0 0 12px 0;
}

#history-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}

.history-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}

.history-type {
  font-weight: 600;
  color: #3498db;
  background: #eaf2f8;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.history-input {
  color: #555;
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-result {
  font-weight: 600;
  color: #27ae60;
  white-space: nowrap;
}

.history-time {
  color: #bdc3c7;
  font-size: 11px;
  white-space: nowrap;
}

#clear-history-btn {
  display: block;
  margin: 0 auto;
}

@media (max-width: 480px) {
  #app {
    padding: 16px 12px;
  }

  #app-title {
    font-size: 24px;
  }

  .mode-tab {
    padding: 10px 14px;
    font-size: 14px;
  }

  .weighted-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
  }

  .weighted-row .weight-label {
    display: none;
  }

  .weighted-row .btn-remove {
    align-self: flex-end;
  }

  .value-input, .weight-input {
    font-size: 16px;
    padding: 12px;
    min-height: 44px;
  }

  #result-value {
    font-size: 28px;
  }

  .btn-primary {
    padding: 14px 20px;
    font-size: 16px;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
